def test_wheel_name_filter(tmpdir): """ Test the wheel cache filters on wheel name when several wheels for different package are stored under the same cache directory. """ wc = WheelCache(tmpdir, FormatControl()) link = Link("https://g.c/package.tar.gz") cache_path = wc.get_path_for_link(link) ensure_dir(cache_path) with open(os.path.join(cache_path, "package-1.0-py3-none-any.whl"), "w"): pass # package matches wheel name assert wc.get(link, "package", [("py3", "none", "any")]) is not link # package2 does not match wheel name assert wc.get(link, "package2", [("py3", "none", "any")]) is link
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))