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

Function test_cli_clear_command

tests/test_cli.py:342–370  ·  view source on GitHub ↗

The `semble clear ` CLI dispatches to _run_clear correctly.

(
    subcommand: str,
    setup_index: bool,
    setup_savings: bool,
    expected_fragments: list[str],
    tmp_path: Path,
    monkeypatch: pytest.MonkeyPatch,
    capsys: pytest.CaptureFixture[str],
)

Source from the content-addressed store, hash-verified

340 ],
341)
342def test_cli_clear_command(
343 subcommand: str,
344 setup_index: bool,
345 setup_savings: bool,
346 expected_fragments: list[str],
347 tmp_path: Path,
348 monkeypatch: pytest.MonkeyPatch,
349 capsys: pytest.CaptureFixture[str],
350) -> None:
351 """The `semble clear <subcommand>` CLI dispatches to _run_clear correctly."""
352 sha = "e" * 64
353 if setup_index:
354 _make_valid_index_dir(tmp_path, sha)
355 savings_file = tmp_path / "savings.jsonl"
356 if setup_savings:
357 savings_file.write_text('{"tokens": 200}\n')
358
359 monkeypatch.setattr(sys, "argv", ["semble", "clear", subcommand])
360 with patch("semble.cli.resolve_cache_folder", return_value=tmp_path):
361 _cli_main()
362
363 out = capsys.readouterr().out
364 for fragment in expected_fragments:
365 assert fragment in out
366
367 if setup_index:
368 assert not (tmp_path / sha).exists()
369 if setup_savings:
370 assert not savings_file.exists()

Callers

nothing calls this directly

Calls 2

_cli_mainFunction · 0.90
_make_valid_index_dirFunction · 0.85

Tested by

no test coverage detected