fix(llm): mock _code_index in index_docs unit tests
F1's index_refs now builds a code_family_index per run by refreshing pfs.families.FAMILIES from the DuckDB replica when it's on disk. tests/llm/test_index.py didn't mock that (llm.index._code_index), so its index_docs tests ran against the real live replica and permanently mutated the global FAMILIES registry — CCM/APCM picked up real derived codes (G0502, G0503, G2058) that then leaked into unrelated tests (tests/cli/test_pfs_cli.py) whenever both files shared a test run.
This commit is contained in:
@@ -35,6 +35,9 @@ def _run(docs, state_rows, force=False, cfg=CFG):
|
|||||||
patch("llm.index.embed_texts", return_value=[[0.0] * 3]),
|
patch("llm.index.embed_texts", return_value=[[0.0] * 3]),
|
||||||
patch("llm.index.ensure_hnsw") as mock_ensure_hnsw,
|
patch("llm.index.ensure_hnsw") as mock_ensure_hnsw,
|
||||||
patch("llm.index.HostPool") as MockPool,
|
patch("llm.index.HostPool") as MockPool,
|
||||||
|
# Real `_code_index` opens the live DuckDB replica — never in a
|
||||||
|
# unit test.
|
||||||
|
patch("llm.index._code_index", return_value={}),
|
||||||
):
|
):
|
||||||
MockPool.return_value.check.return_value = ["http://h1:11434"]
|
MockPool.return_value.check.return_value = ["http://h1:11434"]
|
||||||
stats = index_docs(
|
stats = index_docs(
|
||||||
@@ -138,6 +141,7 @@ class TestDeleteOldChunksFallback:
|
|||||||
patch("llm.index.embed_texts", return_value=[[0.0] * 3]),
|
patch("llm.index.embed_texts", return_value=[[0.0] * 3]),
|
||||||
patch("llm.index.ensure_hnsw"),
|
patch("llm.index.ensure_hnsw"),
|
||||||
patch("llm.index.HostPool") as MockPool,
|
patch("llm.index.HostPool") as MockPool,
|
||||||
|
patch("llm.index._code_index", return_value={}),
|
||||||
):
|
):
|
||||||
MockPool.return_value.check.return_value = ["http://h1:11434"]
|
MockPool.return_value.check.return_value = ["http://h1:11434"]
|
||||||
stats = index_docs(
|
stats = index_docs(
|
||||||
|
|||||||
Reference in New Issue
Block a user