From 29ffeae7d36c6e6c2a10dd230f8472226f51d955 Mon Sep 17 00:00:00 2001 From: Christophe Combelles Date: Wed, 19 May 2010 21:54:20 +0200 Subject: set-up infrastructure to write tests with a real http server, and reproduced issue 163. --HG-- branch : distribute extra : rebase_source : dc3a9fb1663500c66febacbc2ede43eaa96c190e --- setuptools/tests/test_packageindex.py | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'setuptools/tests/test_packageindex.py') diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py index 8ae7a5b9..5c1c6970 100644 --- a/setuptools/tests/test_packageindex.py +++ b/setuptools/tests/test_packageindex.py @@ -5,6 +5,7 @@ import sys import os, shutil, tempfile, unittest, urllib2 import pkg_resources import setuptools.package_index +from server import IndexServer class TestPackageIndex(unittest.TestCase): @@ -74,3 +75,40 @@ class TestPackageIndex(unittest.TestCase): url = 'file:///tmp/test_package_index' self.assert_(index.url_ok(url, True)) + def test_links_priority(self): + """ + Download links from the pypi simple index should be used before + external download links. + http://bitbucket.org/tarek/distribute/issue/163/md5-validation-error + + Usecase : + - someone uploads a package on pypi, a md5 is generated + - someone manually copies this link (with the md5 in the url) onto an + external page accessible from the package page. + - someone reuploads the package (with a different md5) + - while easy_installing, an MD5 error occurs because the external link + is used + -> Distribute should use the link from pypi, not the external one. + """ + # start an index server + server = IndexServer() + server.start() + index_url = server.base_url() + 'test_links_priority/simple/' + + # scan a test index + pi = setuptools.package_index.PackageIndex(index_url) + requirement = pkg_resources.Requirement.parse('foobar') + pi.find_packages(requirement) + server.stop() + + # the distribution has been found + self.assert_('foobar' in pi) + # we have two links + self.assert_(len(pi['foobar'])==2) + # the first link should be from the index + self.assert_('correct_md5' in pi['foobar'][0].location) + # the second link should be the external one + self.assert_('bad_md5' in pi['foobar'][1].location) + + + -- cgit v1.2.3 From f3411291c4ec89df2f9fe18263a5509fb4caaddf Mon Sep 17 00:00:00 2001 From: Christophe Combelles Date: Wed, 19 May 2010 23:11:22 +0200 Subject: fixed issue 163 : don't include md5 when comparing two distributions, and scan index links before external page links. --HG-- branch : distribute extra : rebase_source : d190057280e7cb27317eb4aa40e75f1c851ed6e5 --- setuptools/tests/test_packageindex.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'setuptools/tests/test_packageindex.py') diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py index 5c1c6970..42cb8c1e 100644 --- a/setuptools/tests/test_packageindex.py +++ b/setuptools/tests/test_packageindex.py @@ -103,12 +103,10 @@ class TestPackageIndex(unittest.TestCase): # the distribution has been found self.assert_('foobar' in pi) - # we have two links - self.assert_(len(pi['foobar'])==2) - # the first link should be from the index + # we have only one link, because links are compared without md5 + self.assert_(len(pi['foobar'])==1) + # the link should be from the index self.assert_('correct_md5' in pi['foobar'][0].location) - # the second link should be the external one - self.assert_('bad_md5' in pi['foobar'][1].location) -- cgit v1.2.3