A failed build evicts the entry so the next call can retry.
(cache: _IndexCache, tmp_path: Path)
| 231 | |
| 232 | @pytest.mark.anyio |
| 233 | async 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 |