79 lines
2.4 KiB
Python
79 lines
2.4 KiB
Python
"""Exercise cli/llm.py's `index` seal-skip wiring: sealed/complete dockets
|
|
are excluded from the comment listing, and only pending seals are passed
|
|
through to be re-marked."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
from typer.testing import CliRunner
|
|
|
|
from cli.llm import app
|
|
|
|
runner = CliRunner()
|
|
_STATS = {
|
|
"indexed": 0,
|
|
"skipped": 0,
|
|
"chunks": 0,
|
|
"fingerprint_skipped": 5,
|
|
"hash_skipped": 0,
|
|
"docket_complete": 0,
|
|
}
|
|
|
|
|
|
@patch("llm.index._engine")
|
|
@patch(
|
|
"llm.index.docket_complete",
|
|
return_value={"CMS-2019-0111": "s1", "CMS-2020-0088": "old"},
|
|
)
|
|
@patch("llm.source.iter_comment_refs")
|
|
@patch("llm.pool.HostPool.from_config")
|
|
@patch("llm.index.index_refs")
|
|
@patch("conf.connect.bib")
|
|
@patch("llm.config.load")
|
|
def test_complete_sealed_dockets_are_not_listed(
|
|
mock_load, mock_bib, mock_index, mock_pool, mock_iter, mock_complete, _engine
|
|
):
|
|
mock_load.return_value = MagicMock()
|
|
store = MagicMock()
|
|
store.sealed_dockets.return_value = {"CMS-2019-0111": "s1", "CMS-2020-0088": "s2"}
|
|
mock_bib.return_value = store
|
|
mock_iter.return_value = iter([])
|
|
mock_index.return_value = _STATS
|
|
|
|
result = runner.invoke(app, ["index"])
|
|
|
|
assert result.exit_code == 0, result.output
|
|
kwargs = mock_iter.call_args.kwargs
|
|
assert kwargs["skip_dockets"] == {"CMS-2019-0111"} # seal matches → skipped
|
|
ikw = mock_index.call_args.kwargs
|
|
assert ikw["sealed"] == {
|
|
"CMS-2020-0088": "s2"
|
|
} # re-sealed docket will be re-marked
|
|
assert ikw["mark_complete"] is True
|
|
assert "fp_skipped=5" in result.output
|
|
|
|
|
|
@patch("llm.index._engine")
|
|
@patch("llm.index.docket_complete", return_value={})
|
|
@patch("llm.source.iter_comment_refs")
|
|
@patch("llm.pool.HostPool.from_config")
|
|
@patch("llm.index.index_refs")
|
|
@patch("conf.connect.bib")
|
|
@patch("llm.config.load")
|
|
def test_force_and_limit_disable_skips_and_completion(
|
|
mock_load, mock_bib, mock_index, mock_pool, mock_iter, mock_complete, _engine
|
|
):
|
|
mock_load.return_value = MagicMock()
|
|
store = MagicMock()
|
|
store.sealed_dockets.return_value = {"CMS-2019-0111": "s1"}
|
|
mock_bib.return_value = store
|
|
mock_iter.return_value = iter([])
|
|
mock_index.return_value = _STATS
|
|
|
|
result = runner.invoke(app, ["index", "--force", "--limit", "5"])
|
|
|
|
assert result.exit_code == 0, result.output
|
|
assert mock_iter.call_args.kwargs["skip_dockets"] == set()
|
|
assert mock_index.call_args.kwargs["mark_complete"] is False
|