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

Function test_index_cache_evicts_on_failure

tests/test_mcp.py:233–249  ·  view source on GitHub ↗

A failed build evicts the entry so the next call can retry.

(cache: _IndexCache, tmp_path: Path)

Source from the content-addressed store, hash-verified

231
232@pytest.mark.anyio
233async def test_index_cache_evicts_on_failure(cache: _IndexCache, tmp_path: Path) -> None:
234 """A failed build evicts the entry so the next call can retry."""
235 call_count = 0
236
237 def _failing_then_ok(path: str, **kwargs: object) -> MagicMock:
238 nonlocal call_count
239 call_count += 1
240 if call_count == 1:
241 raise RuntimeError("build failed")
242 return MagicMock()
243
244 with patch("semble.mcp.SembleIndex.from_path", side_effect=_failing_then_ok):
245 with pytest.raises(RuntimeError, match="build failed"):
246 await cache.get(str(tmp_path))
247 result = await cache.get(str(tmp_path))
248 assert result is not None
249 assert call_count == 2
250
251
252@pytest.mark.anyio

Callers

nothing calls this directly

Calls 1

getMethod · 0.80

Tested by

no test coverage detected