Add failing test for legacy cache keys
@@ -71,3 +71,21 @@ def test_get_path_for_link_legacy(tmpdir):
pass
expected_candidates = {"test-pyx-none-any.whl", "test-pyz-none-any.whl"}
assert set(wc._get_candidates(link, "test")) == expected_candidates
+
+
+def test_get_with_legacy_entry_only(tmpdir):
+ """
+ Test that an existing cache entry that was created with the legacy hashing
+ mechanism is actually returned in WheelCache.get().
+ """
+ wc = WheelCache(tmpdir, FormatControl())
+ link = Link("https://g.c/o/r")
+ legacy_path = wc.get_path_for_link_legacy(link)
+ ensure_dir(legacy_path)
+ with open(os.path.join(legacy_path, "test-1.0.0-py3-none-any.whl"), "w"):
+ pass
+ cached_link = wc.get(link, "test", [("py3", "none", "any")])
+ assert (
+ os.path.normcase(os.path.dirname(cached_link.file_path)) ==
+ os.path.normcase(legacy_path)
+ )
