tests.test_cache moduleΒΆ
Tests for the global binary cache.
- tests.test_cache.test_cache_dir_env_override(monkeypatch, tmp_path)[source]ΒΆ
REPOMATIC_CACHE_DIR env var overrides platform default.
- tests.test_cache.test_cache_dir_env_override_tilde(monkeypatch)[source]ΒΆ
REPOMATIC_CACHE_DIR with ~ expands to home directory.
- tests.test_cache.test_cache_dir_darwin(monkeypatch)[source]ΒΆ
macOS uses ~/Library/Caches/repomatic.
- tests.test_cache.test_cache_dir_linux_xdg(monkeypatch)[source]ΒΆ
Linux with XDG_CACHE_HOME uses $XDG_CACHE_HOME/repomatic.
- tests.test_cache.test_cache_dir_linux_default(monkeypatch)[source]ΒΆ
Linux without XDG_CACHE_HOME uses ~/.cache/repomatic.
- tests.test_cache.test_cache_dir_windows_localappdata(monkeypatch)[source]ΒΆ
Windows uses %LOCALAPPDATA%/repomatic/Cache.
- tests.test_cache.test_cache_dir_from_config(monkeypatch, tmp_path)[source]ΒΆ
cache.dir in [tool.repomatic] overrides platform default.
- tests.test_cache.test_cache_dir_env_beats_config(monkeypatch, tmp_path)[source]ΒΆ
REPOMATIC_CACHE_DIR env var takes precedence over config.
- tests.test_cache.test_max_age_days_from_config(monkeypatch)[source]ΒΆ
cache.max-age in [tool.repomatic] overrides field default.
- tests.test_cache.test_max_age_days_env_beats_config(monkeypatch)[source]ΒΆ
REPOMATIC_CACHE_MAX_AGE env var takes precedence over config.
- tests.test_cache.test_cached_binary_path_structure(cache_env)[source]ΒΆ
Cache path follows bin/{tool}/{version}/{platform}/{executable}.
- tests.test_cache.test_get_cached_binary_not_cached(cache_env)[source]ΒΆ
Returns None when the binary is not in the cache.
- tests.test_cache.test_get_cached_binary_exists(cache_env)[source]ΒΆ
Returns the path when the binary exists and is executable.
- tests.test_cache.test_get_cached_binary_not_executable(cache_env)[source]ΒΆ
Returns None when the file exists but is not executable.
- tests.test_cache.test_store_binary_creates_cache_entry(tmp_path, cache_env)[source]ΒΆ
store_binary copies the source file into the cache.
- tests.test_cache.test_store_binary_overwrites_existing(tmp_path, cache_env)[source]ΒΆ
store_binary replaces an existing cached binary atomically.
- tests.test_cache.test_store_binary_triggers_auto_purge(tmp_path, cache_env)[source]ΒΆ
store_binary calls auto_purge after storing.
- tests.test_cache.test_store_binary_stamps_store_time(monkeypatch, tmp_path, cache_env)[source]ΒΆ
A source carrying an old archive mtime is not self-purged on store.
shutil.copy2 preserves the source mtime, which for a binary extracted from a release archive is the upstream build date. auto_purge ages entries by mtime, so without a fresh timestamp the auto_purge call inside store_binary would delete the entry it just stored.
- tests.test_cache.test_store_binary_unwritable_cache_returns_none(tmp_path, cache_env)[source]ΒΆ
An unwritable cache root degrades to
Noneinstead of raising.Matches the fail-soft contract of
store_responseandstore_config: the caller falls back to its staging copy.
- tests.test_cache.test_cache_info_lists_entries(tmp_path, cache_env)[source]ΒΆ
Returns all cached entries with correct metadata.
- tests.test_cache.test_clear_cache_all(tmp_path, cache_env)[source]ΒΆ
clear_cache() removes all entries.
- tests.test_cache.test_clear_cache_specific_tool(tmp_path, cache_env)[source]ΒΆ
clear_cache(tool=β¦) removes only matching tool.
- tests.test_cache.test_clear_cache_max_age(tmp_path, cache_env)[source]ΒΆ
clear_cache(max_age_days=β¦) removes only old entries.
- tests.test_cache.test_clear_cache_prunes_empty_dirs(tmp_path, cache_env)[source]ΒΆ
clear_cache removes empty parent directories after deletion.
- tests.test_cache.test_auto_purge_removes_old_entries(monkeypatch, tmp_path, cache_env)[source]ΒΆ
auto_purge removes entries older than REPOMATIC_CACHE_MAX_AGE.
- tests.test_cache.test_auto_purge_disabled_when_zero(tmp_path, cache_env)[source]ΒΆ
auto_purge does nothing when REPOMATIC_CACHE_MAX_AGE=0.
- tests.test_cache.test_auto_purge_keeps_fresh_entries(monkeypatch, tmp_path, cache_env)[source]ΒΆ
auto_purge keeps entries newer than the threshold.
- tests.test_cache.test_max_age_days_default(monkeypatch)[source]ΒΆ
Returns CacheConfig.max_age when env var is not set.
- tests.test_cache.test_max_age_days_custom(monkeypatch)[source]ΒΆ
Reads integer from REPOMATIC_CACHE_MAX_AGE.
- tests.test_cache.test_max_age_days_zero_disables(monkeypatch)[source]ΒΆ
REPOMATIC_CACHE_MAX_AGE=0 disables auto-purge.
- tests.test_cache.test_max_age_days_invalid_fallback(monkeypatch)[source]ΒΆ
Invalid value falls back to default with a warning.
- tests.test_cache.test_prune_empty_dirs(tmp_path)[source]ΒΆ
Removes empty nested directories but preserves root.
- tests.test_cache.test_prune_empty_dirs_preserves_nonempty(tmp_path)[source]ΒΆ
Preserves directories that contain files.
- tests.test_cache.test_store_and_get_cached_response(cache_env)[source]ΒΆ
Round-trip: store a response, then retrieve it.
- tests.test_cache.test_get_cached_response_zero_ttl(cache_env)[source]ΒΆ
TTL=0 bypasses cache entirely.
- tests.test_cache.test_get_cached_response_negative_ttl(cache_env)[source]ΒΆ
Negative TTL bypasses cache entirely.
- tests.test_cache.test_get_cached_response_missing(cache_env)[source]ΒΆ
Returns None when no cached response exists.
- tests.test_cache.test_get_cached_response_stale(cache_env)[source]ΒΆ
Returns None when cached response is older than max_age_seconds.
- tests.test_cache.test_store_response_nested_key(cache_env)[source]ΒΆ
Keys with slashes create nested directories.
- tests.test_cache.test_http_cache_info_lists_entries(cache_env)[source]ΒΆ
http_cache_info returns all cached responses.
- tests.test_cache.test_http_cache_info_empty(cache_env)[source]ΒΆ
Returns empty list when HTTP cache is empty.
- tests.test_cache.test_clear_http_cache_all(cache_env)[source]ΒΆ
clear_http_cache() removes all HTTP entries.