test: cover embedding device fallback and bounded upserts

Agent-Logs-Url: https://github.com/MemPalace/mempalace/sessions/3213a67a-6871-4bb2-9ae0-23fa11001a22

Co-authored-by: igorls <4753812+igorls@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-24 23:06:50 +00:00
committed by GitHub
parent a4868a3589
commit fbd0904799
7 changed files with 268 additions and 57 deletions
+26
View File
@@ -20,6 +20,32 @@ def test_config_from_file():
assert cfg.palace_path == "/custom/palace"
def test_embedding_device_defaults_to_auto():
cfg = MempalaceConfig(config_dir=tempfile.mkdtemp())
assert cfg.embedding_device == "auto"
def test_embedding_device_from_config_is_normalized():
tmpdir = tempfile.mkdtemp()
with open(os.path.join(tmpdir, "config.json"), "w") as f:
json.dump({"embedding_device": " CUDA "}, f)
cfg = MempalaceConfig(config_dir=tmpdir)
assert cfg.embedding_device == "cuda"
def test_embedding_device_env_overrides_config():
tmpdir = tempfile.mkdtemp()
with open(os.path.join(tmpdir, "config.json"), "w") as f:
json.dump({"embedding_device": "cpu"}, f)
os.environ["MEMPALACE_EMBEDDING_DEVICE"] = " CoreML "
try:
cfg = MempalaceConfig(config_dir=tmpdir)
assert cfg.embedding_device == "coreml"
finally:
del os.environ["MEMPALACE_EMBEDDING_DEVICE"]
def test_env_override():
raw = "/env/palace"
os.environ["MEMPALACE_PALACE_PATH"] = raw