MCPcopy Index your code
hub / github.com/SourceCode-AI/aura / test_package_retrieval

Function test_package_retrieval

tests/test_package.py:42–62  ·  view source on GitHub ↗
(mock_pypi_rest_api)

Source from the content-addressed store, hash-verified

40
41@responses.activate
42def test_package_retrieval(mock_pypi_rest_api):
43 mock_pypi_rest_api(responses)
44 pkg = package.PypiPackage.from_cached("wheel")
45 url = "https://files.pythonhosted.org/packages/8c/23/848298cccf8e40f5bbb59009b32848a4c38f4e7f3364297ab3c3e2e2cd14/wheel-0.34.2-py2.py3-none-any.whl"
46
47 assert pkg.name == "wheel"
48 assert pkg.source == "pypi" # TODO: add tests for other package options
49
50 with pkg.url2local(url) as location:
51 assert location.is_file()
52 file_name = url.split("/")[-1]
53 assert location.name.endswith(file_name), (location, file_name)
54
55 with tempfile.TemporaryDirectory(prefix="aura_pytest_") as tmp:
56 downloaded = [x["filename"] for x in pkg.download_release(tmp, packagetype="all", release="0.34.2")]
57 content = os.listdir(tmp)
58
59 assert "wheel-0.34.2.tar.gz" in downloaded
60 assert "wheel-0.34.2.tar.gz" in content
61 assert "wheel-0.34.2-py2.py3-none-any.whl" in downloaded
62 assert "wheel-0.34.2-py2.py3-none-any.whl" in content
63
64
65@responses.activate

Callers

nothing calls this directly

Calls 4

mock_pypi_rest_apiFunction · 0.85
from_cachedMethod · 0.80
download_releaseMethod · 0.80
url2localMethod · 0.45

Tested by

no test coverage detected