_IndexCache.get() builds via the correct SembleIndex.* entrypoint and caches subsequent calls.
(
cache: _IndexCache, tmp_path: Path, source: str, patch_target: str
)
| 128 | ids=["local_path", "git_url"], |
| 129 | ) |
| 130 | async 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 |
nothing calls this directly
no test coverage detected