MCPcopy Index your code
hub / github.com/idank/explainshell / _run_diff_db_with_store

Method _run_diff_db_with_store

tests/test_manager.py:2057–2094  ·  view source on GitHub ↗

Run _run_diff_db and return captured log lines.

(
        self, gz_path: str, short_path: str, store: Store
    )

Source from the content-addressed store, hash-verified

2055 """Tests for _run_diff_db preferring exact source path over name lookup."""
2056
2057 def _run_diff_db_with_store(
2058 self, gz_path: str, short_path: str, store: Store
2059 ) -> list[str]:
2060 """Run _run_diff_db and return captured log lines."""
2061
2062 fake_mp = _make_manpage_from_source(short_path)
2063 fake_raw = _make_raw()
2064
2065 entry = ExtractionResult(
2066 gz_path=gz_path,
2067 outcome=ExtractionOutcome.SUCCESS,
2068 mp=fake_mp,
2069 raw=fake_raw,
2070 stats=ExtractionStats(),
2071 )
2072
2073 with (
2074 patch("explainshell.manager.make_extractor") as mock_ext,
2075 patch(
2076 "explainshell.manager.config.source_from_path",
2077 return_value=short_path,
2078 ),
2079 patch("explainshell.manager.run") as mock_run,
2080 ):
2081 mock_ext.return_value = MagicMock()
2082
2083 def _fake_run(ext, files, **kwargs):
2084 on_result = kwargs.get("on_result")
2085 if on_result:
2086 on_result(gz_path, entry)
2087 return BatchResult()
2088
2089 mock_run.side_effect = _fake_run
2090
2091 with self.assertLogs("explainshell.manager", level=logging.INFO) as cm:
2092 _run_diff_db([gz_path], "llm", "test-model", None, False, store)
2093
2094 return cm.output
2095
2096 def test_exact_source_match_preferred(self):
2097 """When the exact source path exists in DB, use it directly."""

Calls 5

ExtractionResultClass · 0.90
ExtractionStatsClass · 0.90
_run_diff_dbFunction · 0.90
_make_rawFunction · 0.70

Tested by

no test coverage detected