def test_find_wheels_and_no_sdist(self, loghub): vl = ViewLinkStore("http://something/index", {"+links": [ {"href": "http://b/pytest-2.7.0-py2.py3-none-any.whl", "rel": "releasefile"}, ]}) links = vl.get_links(rel="releasefile") with pytest.raises(SystemExit): find_sdist_and_wheels(loghub, links) loghub._getmatcher().fnmatch_lines(""" *need at least one sdist* """)
def test_find_wheels_non_universal(self, loghub): vl = ViewLinkStore( "http://something/index", { "+links": [ { "href": "http://b/pytest-2.7.0.tar.gz", "rel": "releasefile" }, { "href": "http://b/pytest-2.7.0-py2-none-any.whl", "rel": "releasefile" }, ] }) links = vl.get_links(rel="releasefile") (sdist_links, wheel_links) = find_sdist_and_wheels(loghub, links, universal_only=False) assert len(sdist_links) == 1 assert sdist_links[0].basename.endswith(".tar.gz") assert len(wheel_links) == 1 assert wheel_links[0].basename.endswith("py2-none-any.whl") assert 'only universal wheels' not in '\n'.join( loghub._getmatcher().lines)
def test_find_wheels_and_sdist(self, loghub): vl = ViewLinkStore( "http://something/index", { "+links": [ { "href": "http://b/pytest-2.7.0.zip", "rel": "releasefile" }, { "href": "http://b/pytest-2.7.0.tar.gz", "rel": "releasefile" }, { "href": "http://b/pytest-2.7.0-py2.py3-none-any.whl", "rel": "releasefile" }, ] }) links = vl.get_links(rel="releasefile") sdist_links, wheel_links = find_sdist_and_wheels(loghub, links) assert len(sdist_links) == 2 assert sdist_links[0].basename.endswith(".tar.gz") assert sdist_links[1].basename.endswith(".zip") assert len(wheel_links) == 1 assert wheel_links[0].basename == "pytest-2.7.0-py2.py3-none-any.whl"
def test_prepare_toxrun_args2(self, loghub, pseudo_current, tmpdir, reqmock, initproj): # basically the same test as above, but it's testing the unpack # path for packages that have an underscore in the name vl = ViewLinkStore("http://something/index", {"+links": [ {"href": "http://b/prep_under-1.0.zip", "rel": "releasefile"}, {"href": "http://b/prep_under-1.0.tar.gz", "rel": "releasefile"}, {"href": "http://b/prep_under-1.0-py2.py3-none-any.whl", "rel": "releasefile"}, {"href": "http://b/prep_under-1.0-py2-none-any.whl", "rel": "releasefile"}, ], "name": "prep-under", "version": "1.0"}) links = vl.get_links(rel="releasefile") sdist_links, wheel_links = find_sdist_and_wheels(loghub, links) dev_index = DevIndex(loghub, tmpdir, pseudo_current) initproj("prep_under-1.0", filedefs={}) subprocess.check_call(["python", "setup.py", "sdist", "--formats=gztar,zip"]) subprocess.check_call(["python", "setup.py", "bdist_wheel", "--universal"]) for p in py.path.local("dist").listdir(): reqmock.mockresponse("http://b/" + p.basename, code=200, method="GET", data=p.read("rb")) toxrunargs = prepare_toxrun_args(dev_index, vl, sdist_links, wheel_links) assert len(toxrunargs) == 3 sdist1, sdist2, wheel1 = toxrunargs assert sdist1[0].basename == "prep_under-1.0.tar.gz" assert sdist1[1].path_unpacked.strpath.endswith("targz" + os.sep + "prep_under-1.0") assert sdist2[0].basename == "prep_under-1.0.zip" assert sdist2[1].path_unpacked.strpath.endswith("zip" + os.sep + "prep_under-1.0") assert wheel1[0].basename == "prep_under-1.0-py2.py3-none-any.whl" assert str(wheel1[1].path_unpacked).endswith(wheel1[0].basename)
def test_prepare_toxrun_args(self, loghub, pseudo_current, tmpdir, reqmock, initproj): # XXX this test was a bit hard to setup and is also somewhat covered by # the below wheel functional test so unclear if it's worth to # maintain it (but now that we have it ...) vl = ViewLinkStore("http://something/index", {"+links": [ {"href": "http://b/prep1-1.0.zip", "rel": "releasefile"}, {"href": "http://b/prep1-1.0.tar.gz", "rel": "releasefile"}, {"href": "http://b/prep1-1.0-py2.py3-none-any.whl", "rel": "releasefile"}, {"href": "http://b/prep1-1.0-py2-none-any.whl", "rel": "releasefile"}, ], "name": "prep1", "version": "1.0"}) links = vl.get_links(rel="releasefile") sdist_links, wheel_links = find_sdist_and_wheels(loghub, links) dev_index = DevIndex(loghub, tmpdir, pseudo_current) initproj("prep1-1.0", filedefs={}) subprocess.check_call(["python", "setup.py", "sdist", "--formats=gztar,zip"]) subprocess.check_call(["python", "setup.py", "bdist_wheel", "--universal"]) for p in py.path.local("dist").listdir(): reqmock.mockresponse("http://b/" + p.basename, code=200, method="GET", data=p.read("rb")) toxrunargs = prepare_toxrun_args(dev_index, vl, sdist_links, wheel_links) assert len(toxrunargs) == 3 sdist1, sdist2, wheel1 = toxrunargs assert sdist1[0].basename == "prep1-1.0.tar.gz" assert sdist1[1].path_unpacked.strpath.endswith("targz" + os.sep + "prep1-1.0") assert sdist2[0].basename == "prep1-1.0.zip" assert sdist2[1].path_unpacked.strpath.endswith("zip" + os.sep + "prep1-1.0") assert wheel1[0].basename == "prep1-1.0-py2.py3-none-any.whl" assert str(wheel1[1].path_unpacked).endswith(wheel1[0].basename)
def test_find_wheels_not_universal(self, loghub): vl = ViewLinkStore("http://something/index", {"+links": [ {"href": "http://b/pytest-2.7.0.tar.gz", "rel": "releasefile"}, {"href": "http://b/pytest-2.7.0-py26-none-any.whl", "rel": "releasefile"}, ]}) links = vl.get_links(rel="releasefile") (sdist_links, wheel_links) = find_sdist_and_wheels(loghub, links) assert len(sdist_links) == 1 assert sdist_links[0].basename.endswith(".tar.gz") assert len(wheel_links) == 0 loghub._getmatcher().fnmatch_lines(""" *only universal wheels* """)
def test_prepare_toxrun_args_select(self, loghub, pseudo_current, tmpdir, reqmock, initproj): # test that we can explicitly select a non universal wheel pyver = "py%s" % sys.version_info[0] vl = ViewLinkStore( "http://something/index", { "+links": [ { "href": "http://b/prep_under-1.0.tar.gz", "rel": "releasefile" }, { "href": "http://b/prep_under-1.0-%s-none-any.whl" % pyver, "rel": "releasefile" }, ], "name": "prep-under", "version": "1.0" }) links = vl.get_links(rel="releasefile") sdist_links, wheel_links = find_sdist_and_wheels(loghub, links, universal_only=False) dev_index = DevIndex(loghub, tmpdir, pseudo_current) initproj("prep_under-1.0", filedefs={}) subprocess.check_call( ["python", "setup.py", "sdist", "--formats=gztar"]) subprocess.check_call(["python", "setup.py", "bdist_wheel"]) for p in py.path.local("dist").listdir(): reqmock.mockresponse("http://b/" + p.basename, code=200, method="GET", data=p.read("rb")) toxrunargs = prepare_toxrun_args(dev_index, vl, sdist_links, wheel_links, select=pyver) assert len(toxrunargs) == 1 (wheel1, ) = toxrunargs assert wheel1[0].basename == "prep_under-1.0-%s-none-any.whl" % pyver assert str(wheel1[1].path_unpacked).endswith(wheel1[0].basename)