_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],
)
| 34 | ], |
| 35 | ) |
| 36 | def 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( |
nothing calls this directly
no test coverage detected