Skip to content

Commit 9c74c02

Browse files
committed
Add failing test for legacy cache keys
1 parent b2fcaac commit 9c74c02

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/unit/test_cache.py

+18
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,21 @@ def test_get_path_for_link_legacy(tmpdir):
7171
pass
7272
expected_candidates = {"test-pyx-none-any.whl", "test-pyz-none-any.whl"}
7373
assert set(wc._get_candidates(link, "test")) == expected_candidates
74+
75+
76+
def test_get_with_legacy_entry_only(tmpdir):
77+
"""
78+
Test that an existing cache entry that was created with the legacy hashing
79+
mechanism is actually returned in WheelCache.get().
80+
"""
81+
wc = WheelCache(tmpdir, FormatControl())
82+
link = Link("https://g.c/o/r")
83+
legacy_path = wc.get_path_for_link_legacy(link)
84+
ensure_dir(legacy_path)
85+
with open(os.path.join(legacy_path, "test-1.0.0-py3-none-any.whl"), "w"):
86+
pass
87+
cached_link = wc.get(link, "test", [("py3", "none", "any")])
88+
assert (
89+
os.path.normcase(os.path.dirname(cached_link.file_path)) ==
90+
os.path.normcase(legacy_path)
91+
)

0 commit comments

Comments
 (0)