MCPcopy
hub / github.com/MinishLab/semble / test_run_clear_index

Function test_run_clear_index

tests/test_cli.py:253–280  ·  view source on GitHub ↗

_run_clear('index') finds valid indexes, and skips non-SHA/incomplete/empty dirs.

(
    scenario: str, expected_in_output: list[str], tmp_path: Path, capsys: pytest.CaptureFixture[str]
)

Source from the content-addressed store, hash-verified

251 ],
252)
253def test_run_clear_index(
254 scenario: str, expected_in_output: list[str], tmp_path: Path, capsys: pytest.CaptureFixture[str]
255) -> None:
256 """_run_clear('index') finds valid indexes, and skips non-SHA/incomplete/empty dirs."""
257 if scenario == "valid":
258 _make_valid_index_dir(tmp_path, "a" * 64)
259 _make_valid_index_dir(tmp_path, "b" * 64)
260 elif scenario == "non_sha":
261 bad_dir = tmp_path / "not-a-sha" / "index"
262 bad_dir.mkdir(parents=True)
263 (bad_dir / "chunks.json").write_text("[]")
264 (bad_dir / "bm25_index").write_text("")
265 (bad_dir / "semantic_index").write_text("")
266 (bad_dir / "metadata.json").write_text("{}")
267 elif scenario == "incomplete":
268 index_dir = tmp_path / ("c" * 64) / "index"
269 index_dir.mkdir(parents=True)
270
271 with patch("semble.cli.resolve_cache_folder", return_value=tmp_path):
272 _run_clear("index")
273
274 out = capsys.readouterr().out
275 for fragment in expected_in_output:
276 assert fragment in out
277
278 if scenario == "valid":
279 assert not (tmp_path / ("a" * 64)).exists()
280 assert not (tmp_path / ("b" * 64)).exists()
281
282
283@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 2

_run_clearFunction · 0.90
_make_valid_index_dirFunction · 0.85

Tested by

no test coverage detected