Пример #1
0
 def test_parse_index_simple_tilde(self):
     result = parse_index(
         self.simplepy,
         """<a href="/~user/py-1.4.12.zip#md5=12ab">qwe</a>""")
     link, = result.releaselinks
     assert link.basename == "py-1.4.12.zip"
     assert link.url.endswith("/~user/py-1.4.12.zip#md5=12ab")
Пример #2
0
 def test_parse_index_with_wheel(self):
     result = parse_index(self.simplepy,
         """<a href="pkg/py-1.0-cp27-none-linux_x86_64.whl" />
     """)
     assert len(result.releaselinks) == 1
     link, = result.releaselinks
     assert link.basename == "py-1.0-cp27-none-linux_x86_64.whl"
Пример #3
0
 def test_parse_index_two_eggs_same_url(self):
     simplepy = URL("https://pypi.org/simple/Py/")
     result = parse_index(
         simplepy, """<a href="../../pkg/pyzip#egg=py-dev">qwe2</a>
            <a href="../../pkg/pyzip#egg=py-dev">qwe</a>
     """)
     assert len(result.releaselinks) == 1
Пример #4
0
 def test_parse_index_normalized_name(self):
     simplepy = URL("https://pypi.org/simple/ndg-httpsclient/")
     result = parse_index(simplepy, """
            <a href="../../pkg/ndg_httpsclient-1.0.tar.gz" />
     """)
     assert len(result.releaselinks) == 1
     assert result.releaselinks[0].url.endswith("ndg_httpsclient-1.0.tar.gz")
Пример #5
0
 def test_releasefile_md5_matching_and_ordering(self):
     """ check that md5-links win over non-md5 links anywhere.
     And otherwise the links from the index page win over scraped ones.
     """
     result = parse_index(
         self.simplepy,
         """<a href="../../pkg/py-1.4.12.zip#md5=12ab">qwe</a>
            <a href="../../pkg/py-1.4.11.zip">qwe</a>
            <a href="../../pkg/py-1.4.10.zip#md5=2222">qwe</a>
            <a href="http://pylib.org" rel="homepage">whatever</a>
            <a href="http://pylib2.org" rel="download">whatever2</a>
     """)
     assert len(result.releaselinks) == 3
     assert len(result.crawllinks) == 2
     result.parse_index(URL("http://pylib.org"),
                        """
            <a href="http://pylib.org/py-1.4.12.zip" />
            <a href="http://pylib.org/py-1.4.11.zip#md5=1111" />
            <a href="http://pylib.org/py-1.4.10.zip#md5=12ab" />
     """,
                        scrape=False)
     assert len(result.crawllinks) == 2
     assert len(result.releaselinks) == 3
     link1, link2, link3 = result.releaselinks
     assert link1.url == "https://pypi.org/pkg/py-1.4.12.zip#md5=12ab"
     assert link2.url == "http://pylib.org/py-1.4.11.zip#md5=1111"
     assert link3.url == "https://pypi.org/pkg/py-1.4.10.zip#md5=2222"
Пример #6
0
 def test_parse_index_simple_dir_egg_issue63(self):
     simplepy = URL("https://pypi.org/simple/py/")
     result = parse_index(
         simplepy, """<a href="../../pkg/py-1.4.12.zip#md5=12ab">qwe</a>
            <a href="../../pkg/#egg=py-dev">qwe</a>
     """)
     assert len(result.releaselinks) == 1
Пример #7
0
 def test_parse_index_simple_nocase(self):
     simplepy = URL("https://pypi.org/simple/Py/")
     result = parse_index(
         simplepy, """<a href="../../pkg/py-1.4.12.zip#md5=12ab">qwe</a>
            <a href="../../pkg/PY-1.4.13.zip">qwe</a>
     """)
     assert len(result.releaselinks) == 2
Пример #8
0
 def test_parse_index_with_requires_python(self):
     result = parse_index(self.simplepy,
         """<a href="pkg/py-1.0.zip" data-requires-python="&lt;3" />
     """)
     assert len(result.releaselinks) == 1
     link, = result.releaselinks
     assert link.basename == "py-1.0.zip"
     assert link.requires_python == "<3"
Пример #9
0
 def test_parse_index_with_yanked(self):
     result = parse_index(
         self.simplepy,
         """<a href="pkg/py-1.0.zip" data-yanked="" />""")
     assert len(result.releaselinks) == 1
     link, = result.releaselinks
     assert link.basename == "py-1.0.zip"
     assert link.yanked is True
Пример #10
0
 def test_parse_index_ftp_ignored_for_now(self):
     result = parse_index(
         self.simplepy, """<a href="http://bb.org/download/py-1.0.zip" />
            <a href="ftp://bb.org/download/py-1.0.tar.gz" />
            <a rel="download" href="ftp://bb.org/download/py-1.1.tar.gz" />
     """)
     assert len(result.releaselinks) == 1
     link, = result.releaselinks
     assert link.basename == "py-1.0.zip"
Пример #11
0
 def test_parse_index_with_yanked_first_with_hash_spec_kept(self):
     result = parse_index(self.simplepy,
         """<a href="pkg/py-1.0.zip#md5=pony"/>
            <a href="pkg/py-1.0.zip#md5=pony" data-yanked="" />
     """)
     assert len(result.releaselinks) == 1
     link, = result.releaselinks
     assert link.basename == "py-1.0.zip"
     assert link.hash_spec == "md5=pony"
     assert link.yanked is False
Пример #12
0
 def test_parse_index_with_rel(self, rel):
     result = parse_index(self.simplepy, """
            <a href="http://pylib.org" rel="%s">whatever</a>
            <a href="http://pylib2.org" rel="%s">whatever2</a>
            <a href="http://pylib3.org">py-1.0.zip</a>
            <a href="http://pylib2.org/py-1.0.zip" rel="%s">whatever2</a>
     """ % (rel,rel, rel))
     assert len(result.releaselinks) == 1
     link, = result.releaselinks
     assert link == "http://pylib2.org/py-1.0.zip"
Пример #13
0
 def test_parse_index_with_requires_python_first_with_hash_spec_kept(self):
     result = parse_index(
         self.simplepy, """<a href="pkg/py-1.0.zip#md5=pony"/>
            <a href="pkg/py-1.0.zip#md5=pony" data-requires-python="&lt;3" />
     """)
     assert len(result.releaselinks) == 1
     link, = result.releaselinks
     assert link.basename == "py-1.0.zip"
     assert link.hash_spec == "md5=pony"
     assert link.requires_python is None
Пример #14
0
 def test_parse_index_simple_hash_types(self, hash_type, hash_value):
     result = parse_index(
         self.simplepy, """<a href="../../pkg/py-1.4.12.zip#%s=%s" /a>""" %
         (hash_type, hash_value))
     link, = result.releaselinks
     assert link.basename == "py-1.4.12.zip"
     assert link.hash_spec == "%s=%s" % (hash_type, hash_value)
     if hash_type == "md5":
         assert link.md5 == hash_value
     else:
         assert link.md5 is None
     assert link.hash_algo == getattr(hashlib, hash_type)
Пример #15
0
 def test_parse_index_with_egg(self):
     result = parse_index(
         self.simplepy,
         """<a href="http://bb.org/download/py.zip#egg=py-dev" />
            <a href="http://bb.org/download/py-1.0.zip" />
            <a href="http://bb.org/download/py.zip#egg=something-dev" />
     """)
     assert len(result.releaselinks) == 2
     link, link2 = result.releaselinks
     assert link.basename == "py.zip"
     assert link.eggfragment == "py-dev"
     assert link2.basename == "py-1.0.zip"
Пример #16
0
 def test_releasefile_and_scrape(self):
     result = parse_index(self.simplepy,
         """<a href="../../pkg/py-1.4.12.zip#md5=12ab">qwe</a>
            <a href="http://pylib.org" rel="homepage">whatever</a>
            <a href="http://pylib2.org" rel="download">whatever2</a>
     """)
     assert len(result.releaselinks) == 1
     result.parse_index(URL("http://pylib.org"), """
            <a href="http://pylib.org/py-1.1-py27.egg" />
            <a href="http://pylib.org/other" rel="download" />
     """)
     assert len(result.releaselinks) == 2
     links = list(result.releaselinks)
     assert links[0].url == "https://pypi.org/pkg/py-1.4.12.zip#md5=12ab"
     assert links[1].url == "http://pylib.org/py-1.1-py27.egg"
Пример #17
0
 def test_parse_index_with_two_eggs_ordering(self):
     # it seems that pip/easy_install in some cases
     # rely on the exact ordering of eggs in the html page
     # for example with nose, there are two eggs and the second/last
     # one is chosen due to the internal pip/easy_install algorithm
     result = parse_index(
         self.simplepy,
         """<a href="http://bb.org/download/py.zip#egg=py-dev" />
            <a href="http://other/master#egg=py-dev" />
     """)
     assert len(result.releaselinks) == 2
     link1, link2 = result.releaselinks
     assert link1.basename == "master"
     assert link1.eggfragment == "py-dev"
     assert link2.basename == "py.zip"
     assert link2.eggfragment == "py-dev"
Пример #18
0
 def test_parse_index_egg_svnurl(self, monkeypatch):
     # strange case reported by fschulze/witsch where
     # urlparsing will yield a fragment for svn urls.
     # it's not exactly clear how urlparse.uses_fragment
     # sometimes contains "svn" but it's good to check
     # that we are not sensitive to the issue.
     try:
         import urllib.parse as urlparse
     except ImportError:
         # PY2
         import urlparse
     monkeypatch.setattr(urlparse, "uses_fragment",
                         urlparse.uses_fragment + ["svn"])
     simplepy = URL("https://pypi.org/simple/zope.sqlalchemy/")
     result = parse_index(
         simplepy, '<a href="svn://svn.zope.org/repos/main/'
         'zope.sqlalchemy/trunk#egg=zope.sqlalchemy-dev" />')
     assert len(result.releaselinks) == 0
     assert len(result.egglinks) == 0
Пример #19
0
 def test_parse_index_invalid_link(self, pypistage):
     result = parse_index(
         self.simplepy, '''
             <a rel="download" href="https:/host.com/123" />
     ''')
     assert result.releaselinks == []
Пример #20
0
 def test_parse_index_with_valid_basenames(self, basename):
     result = parse_index(self.simplepy, '<a href="pkg/%s" />' % basename)
     assert len(result.releaselinks) == 1
     link, = result.releaselinks
     assert link.basename == basename
Пример #21
0
 def test_parse_index_invalid_link(self, pypistage):
     result = parse_index(
         self.simplepy, '''
             <a rel="download" href="https:/host.com/123" />
     ''')
     assert result.crawllinks == {URL('https://pypi.org/host.com/123')}
Пример #22
0
 def test_parse_index_unparseable_url(self):
     simple = URL("https://pypi.org/simple/x123/")
     result = parse_index(simple, '<a href="http:" />')
     assert len(result.releaselinks) == 0
Пример #23
0
 def test_releasefile_and_scrape_no_ftp(self):
     result = parse_index(
         self.simplepy, """<a href="ftp://pylib2.org/py-1.0.tar.gz"
               rel="download">whatever2</a> """)
     assert len(result.releaselinks) == 0
     assert len(result.crawllinks) == 0
Пример #24
0
 def test_parse_index_with_non_parseable_hrefs(self):
     result = parse_index(
         self.simplepy, """<a href="qlkwje 1lk23j123123" />
         <a href="http://bb.org/download/py-1.0.zip" />""")
     assert len(result.releaselinks) == 1
Пример #25
0
 def test_parse_index_with_matchingproject_no_version(self):
     result = parse_index(
         self.simplepy, """<a href="http://bb.org/download/p.zip" />
         <a href="http://bb.org/download/py-1.0.zip" />""")
     assert len(result.releaselinks) == 1
Пример #26
0
 def test_parse_index_simple_nomatch(self):
     result = parse_index(self.simplepy,
                          """<a href="../../pkg/py-1.3.html">qwe</a>""")
     assert not result.releaselinks
Пример #27
0
 def test_parse_index_with_num_in_project(self):
     simple = URL("https://pypi.org/simple/py-4chan/")
     result = parse_index(simple, '<a href="pkg/py-4chan-1.0.zip"/>')
     assert len(result.releaselinks) == 1
     assert result.releaselinks[0].basename == "py-4chan-1.0.zip"