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", [Tag("py3", "none", "any")]) assert (os.path.normcase(os.path.dirname( cached_link.file_path)) == os.path.normcase(legacy_path))
def test_get_path_for_link_legacy(tmpdir): """ Test that an existing cache entry that was created with the legacy hashing mechanism is used. """ wc = WheelCache(tmpdir, FormatControl()) link = Link("https://g.c/o/r") path = wc.get_path_for_link(link) legacy_path = wc.get_path_for_link_legacy(link) assert path != legacy_path ensure_dir(path) with open(os.path.join(path, "test-pyz-none-any.whl"), "w"): pass ensure_dir(legacy_path) with open(os.path.join(legacy_path, "test-pyx-none-any.whl"), "w"): pass expected_candidates = {"test-pyx-none-any.whl", "test-pyz-none-any.whl"} assert set(wc._get_candidates(link, "test")) == expected_candidates