def test_package_with_version_specs(self, monkeypatch, specs, link): indexurl = "http://my/simple/" current = Current() current.reconfigure(dict(simpleindex=indexurl)) ri = RemoteIndex(current) def mockget(url): assert url.startswith(indexurl) assert url.endswith("pkg/") return url, """ <a href="http://my/pkg-0.3.tar.gz"/> <a href="http://my/pkg-0.2.8.tar.gz"/> <a href="http://my/pkg-0.2.7.tar.gz"/> <a href="http://my/pkg-0.2.6.tar.gz"/> <a href="http://my/pkg-0.2.5.tar.gz"/> <a href="http://my/pkg-0.2.5a1.tar.gz"/> <a href="http://my/pkg-0.2.4.1.tar.gz"/> <a href="http://my/pkg-0.2.4.tar.gz"/> <a href="http://my/pkg-0.2.3.tar.gz"/> <a href="http://my/pkg-0.2.2.tar.gz"/> <a href="http://my/pkg-0.2.1.tar.gz"/> <a href="http://my/pkg-0.2.0.tar.gz"/> """ monkeypatch.setattr(ri, "getcontent", mockget) lnk = ri.getbestlink(specs) assert URL(lnk.url).url_nofrag == link
def remoteindex(self): try: return self._remoteindex except AttributeError: from devpi.remoteindex import RemoteIndex self._remoteindex = RemoteIndex(self.current) return self._remoteindex
def test_receive_error(self, monkeypatch, tmpdir): indexurl = "http://my/simple/" current = Current(tmpdir.join("client")) current.reconfigure(dict(simpleindex=indexurl)) ri = RemoteIndex(current) def mockget(url): raise ri.ReceiveError(404) monkeypatch.setattr(ri, "getcontent", mockget) link = ri.getbestlink("pkg") assert link is None
def test_basic(self, monkeypatch, gen, tmpdir): md5 = gen.md5() indexurl = "http://my/simple/" current = Current(tmpdir.join("client")) current.reconfigure(dict(simpleindex=indexurl)) ri = RemoteIndex(current) def mockget(url): assert url.startswith(indexurl) return url, """ <a href="../../pkg-1.2.tar.gz#md5=%s"/> <a href="http://something/pkg-1.2dev1.zip"/> <a href="http://something/pkg-1.2dev2.zip"/> """ % md5 monkeypatch.setattr(ri, "getcontent", mockget) link = ri.getbestlink("pkg") assert URL(link.url).url_nofrag == "http://my/pkg-1.2.tar.gz"
def __init__(self, hub, rootdir, current): self.rootdir = rootdir self.current = current self.hub = hub self.remoteindex = RemoteIndex(current) self.dir_download = self.rootdir.mkdir("downloads")