def test_parse_and_scrape(self, pypistage): md5 = getmd5("123") pypistage.mock_simple("pytest", text=''' <a href="../../pkg/pytest-1.0.zip#md5={md5}" /> <a rel="download" href="https://download.com/index.html" /> '''.format(md5=md5), pypiserial=20) pypistage.url2response["https://download.com/index.html"] = dict( status_code=200, text = ''' <a href="pytest-1.1.tar.gz" /> ''', headers = {"content-type": "text/html"}) links = pypistage.get_releaselinks("pytest") assert len(links) == 2 assert links[0].entry.url == "https://download.com/pytest-1.1.tar.gz" assert links[0].entrypath.endswith("/pytest-1.1.tar.gz") links = pypistage.get_linkstore_perstage("pytest", "1.0").get_links() assert len(links) == 1 assert links[0].basename == "pytest-1.0.zip" assert links[0].entry.hash_spec.startswith("md5=") assert links[0].entry.hash_spec.endswith(md5) # check refresh hashdir_b = getmd5("456") pypistage.mock_simple("pytest", text=''' <a href="../../pkg/pytest-1.0.1.zip#md5={hashdir_b}" /> <a href="../../pkg/pytest-1.0.zip#md5={md5}" /> <a rel="download" href="https://download.com/index.html" /> '''.format(md5=md5, hashdir_b=hashdir_b), pypiserial=25) links = pypistage.get_releaselinks("pytest") assert len(links) == 3 assert links[1].entry.url == "https://pypi.python.org/pkg/pytest-1.0.1.zip" assert links[1].entrypath.endswith("/pytest-1.0.1.zip")
def test_parse_and_scrape(self, pypistage): md5 = getmd5("123") pypistage.mock_simple("pytest", text=''' <a href="../../pkg/pytest-1.0.zip#md5={md5}" /> <a rel="download" href="https://download.com/index.html" /> '''.format(md5=md5), pypiserial=20) pypistage.url2response["https://download.com/index.html"] = dict( status_code=200, text=''' <a href="pytest-1.1.tar.gz" /> ''', headers={"content-type": "text/html"}) links = pypistage.get_releaselinks("pytest") assert len(links) == 2 assert links[0].entry.url == "https://download.com/pytest-1.1.tar.gz" assert links[0].entrypath.endswith("/pytest-1.1.tar.gz") links = pypistage.get_linkstore_perstage("pytest", "1.0").get_links() assert len(links) == 1 assert links[0].basename == "pytest-1.0.zip" assert links[0].entry.hash_spec.startswith("md5=") assert links[0].entry.hash_spec.endswith(md5) # check refresh hashdir_b = getmd5("456") pypistage.mock_simple("pytest", text=''' <a href="../../pkg/pytest-1.0.1.zip#md5={hashdir_b}" /> <a href="../../pkg/pytest-1.0.zip#md5={md5}" /> <a rel="download" href="https://download.com/index.html" /> '''.format(md5=md5, hashdir_b=hashdir_b), pypiserial=25) links = pypistage.get_releaselinks("pytest") assert len(links) == 3 assert links[ 1].entry.url == "https://pypi.python.org/pkg/pytest-1.0.1.zip" assert links[1].entrypath.endswith("/pytest-1.0.1.zip")
def test_scrape_not_recursive(self, pypistage): pypistage.mock_simple("pytest", text=''' <a rel="download" href="https://download.com/index.html" /> ''') md5=getmd5("hello") pypistage.url2response["https://download.com/index.html"] = dict( status_code=200, text = ''' <a href="../../pkg/pytest-1.0.zip#md5={md5}" /> <a rel="download" href="http://whatever.com" />'''.format( md5=md5), headers = {"content-type": "text/html"}, ) pypistage.url2response["https://whatever.com"] = dict( status_code=200, text = '<a href="pytest-1.1.zip#md5={md5}" />' .format(md5=md5)) links = pypistage.get_releaselinks("pytest") assert len(links) == 1
def test_scrape_not_recursive(self, pypistage): pypistage.mock_simple("pytest", text=''' <a rel="download" href="https://download.com/index.html" /> ''') md5 = getmd5("hello") pypistage.url2response["https://download.com/index.html"] = dict( status_code=200, text=''' <a href="../../pkg/pytest-1.0.zip#md5={md5}" /> <a rel="download" href="http://whatever.com" />'''.format( md5=md5), headers={"content-type": "text/html"}, ) pypistage.url2response["https://whatever.com"] = dict( status_code=200, text='<a href="pytest-1.1.zip#md5={md5}" />'.format(md5=md5)) links = pypistage.get_releaselinks("pytest") assert len(links) == 1