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

Function test_cli_search

tests/test_cli.py:36–52  ·  view source on GitHub ↗

_cli_main search subcommand calls index.search and prints results.

(
    argv: list[str],
    expected_in_output: list[str],
    monkeypatch: pytest.MonkeyPatch,
    capsys: pytest.CaptureFixture[str],
)

Source from the content-addressed store, hash-verified

34 ],
35)
36def test_cli_search(
37 argv: list[str],
38 expected_in_output: list[str],
39 monkeypatch: pytest.MonkeyPatch,
40 capsys: pytest.CaptureFixture[str],
41) -> None:
42 """_cli_main search subcommand calls index.search and prints results."""
43 chunk = make_chunk("def foo(): pass", "src/foo.py")
44 fake_index = MagicMock()
45 has_results = "No results" not in expected_in_output[0]
46 fake_index.search.return_value = [SearchResult(chunk=chunk, score=0.9)] if has_results else []
47 monkeypatch.setattr(sys, "argv", argv)
48 with patch("semble.cli.SembleIndex.from_path", return_value=fake_index):
49 _cli_main()
50 out = capsys.readouterr().out
51 for fragment in expected_in_output:
52 assert fragment in out
53
54
55@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 3

make_chunkFunction · 0.90
SearchResultClass · 0.90
_cli_mainFunction · 0.90

Tested by

no test coverage detected