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

Function test_index_cache_builds_and_caches

tests/test_mcp.py:130–146  ·  view source on GitHub ↗

_IndexCache.get() builds via the correct SembleIndex.* entrypoint and caches subsequent calls.

(
    cache: _IndexCache, tmp_path: Path, source: str, patch_target: str
)

Source from the content-addressed store, hash-verified

128 ids=["local_path", "git_url"],
129)
130async def test_index_cache_builds_and_caches(
131 cache: _IndexCache, tmp_path: Path, source: str, patch_target: str
132) -> None:
133 """_IndexCache.get() builds via the correct SembleIndex.* entrypoint and caches subsequent calls."""
134 resolved_source = str(tmp_path) if source == "local_tmp_path" else source
135 fake_index = MagicMock()
136 with (
137 patch(f"semble.mcp.SembleIndex.{patch_target}", return_value=fake_index) as mock_build,
138 patch("semble.mcp.save_index_to_cache") as mock_save,
139 patch("semble.mcp.get_validated_cache", return_value=Path("/fake/cache")),
140 ):
141 first = await cache.get(resolved_source)
142 second = await cache.get(resolved_source)
143 assert first is fake_index
144 assert second is fake_index
145 mock_build.assert_called_once()
146 mock_save.assert_called_once_with(fake_index, cache._compute_cache_key(resolved_source))
147
148
149@pytest.mark.anyio

Callers

nothing calls this directly

Calls 2

getMethod · 0.80
_compute_cache_keyMethod · 0.80

Tested by

no test coverage detected