Returns None when a tracked file is newer than the index; the path otherwise.
(
write_time: float, walk_result: str | list, write: bool, expected: str | None, tmp_path: Path
)
| 302 | ], |
| 303 | ) |
| 304 | def test_get_validated_cache_mtime( |
| 305 | write_time: float, walk_result: str | list, write: bool, expected: str | None, tmp_path: Path |
| 306 | ) -> None: |
| 307 | """Returns None when a tracked file is newer than the index; the path otherwise.""" |
| 308 | index_path = tmp_path / "index" |
| 309 | stale_file = tmp_path / "src.py" |
| 310 | stale_file.write_text("x = 1" if write else "") |
| 311 | files = [stale_file] if walk_result == "stale" else walk_result |
| 312 | # Include the file in stored manifest so manifest check passes and mtime check fires. |
| 313 | stored_files = ["src.py"] if walk_result == "stale" else [] |
| 314 | _write_metadata(index_path, "my/model", ["code"], write_time, file_paths=stored_files) |
| 315 | |
| 316 | with patch("semble.cache.find_index_from_cache_folder", return_value=index_path): |
| 317 | with patch("semble.cache.get_extensions", return_value={".py"}): |
| 318 | with patch("semble.cache.walk_files", return_value=files): |
| 319 | result = get_validated_cache(str(tmp_path), "my/model", [ContentType.CODE]) |
| 320 | assert result == (index_path if expected == "index" else None) |
| 321 | |
| 322 | |
| 323 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected