Пример #1
0
 def test_fallback_packages_redirect(self):
     """Fetch fallback packages with redirect URLs"""
     self.request.locator = MagicMock()
     version = "1.1"
     name = "foo"
     filename = "%s-%s.tar.gz" % (name, version)
     url = "https://pypi.org/pypi/%s/%s" % (name, filename)
     wheelname = "%s-%s.whl" % (name, version)
     wheel_url = "https://pypi.org/pypi/%s/%s" % (name, wheelname)
     dist = make_dist(url, name, version)
     wheel_dist = make_dist(wheel_url, name, version)
     self.request.locator.get_releases.return_value = [dist, wheel_dist]
     pkgs = get_fallback_packages(self.request, "foo")
     self.assertEqual(
         pkgs,
         {
             filename: {
                 "url": url,
                 "requires_python": dist["requires_python"],
                 "hash_md5": None,
                 "hash_sha256": None,
             },
             wheelname: {
                 "url": wheel_url,
                 "requires_python": wheel_dist["requires_python"],
                 "hash_md5": None,
                 "hash_sha256": None,
             },
         },
     )
Пример #2
0
 def test_fallback_packages_redirect(self):
     """ Fetch fallback packages with redirect URLs """
     self.request.locator = MagicMock()
     version = "1.1"
     name = "foo"
     filename = "%s-%s.tar.gz" % (name, version)
     url = "https://pypi.org/pypi/%s/%s" % (name, filename)
     wheelname = "%s-%s.whl" % (name, version)
     wheel_url = "https://pypi.org/pypi/%s/%s" % (name, wheelname)
     dist = MagicMock()
     dist.name = name
     self.request.locator.get_project.return_value = {
         version: dist,
         "urls": {
             version: [url, wheel_url]
         },
     }
     pkgs = get_fallback_packages(self.request, "foo")
     self.assertEqual(pkgs, {
         filename: {
             "url": url
         },
         wheelname: {
             "url": wheel_url
         }
     })
Пример #3
0
 def test_fallback_packages(self):
     """ Fetch fallback packages """
     self.request.locator = MagicMock()
     version = '1.1'
     name = 'foo'
     filename = '%s-%s.tar.gz' % (name, version)
     url = 'http://pypi.python.org/pypi/%s/%s' % (name, filename)
     wheelname = '%s-%s.whl' % (name, version)
     wheel_url = 'http://pypi.python.org/pypi/%s/%s' % (name, wheelname)
     dist = MagicMock()
     dist.name = name
     self.request.locator.get_project.return_value = {
         version: dist,
         'urls': {
             version: [url, wheel_url]
         }
     }
     self.request.app_url = MagicMock()
     pkgs = get_fallback_packages(self.request, 'foo', False)
     self.request.app_url.assert_any_call('api', 'package', name, filename)
     self.request.app_url.assert_any_call('api', 'package', name, wheelname)
     self.assertEqual(pkgs, {
         filename: self.request.app_url(),
         wheelname: self.request.app_url(),
     })
Пример #4
0
 def test_fallback_packages(self):
     """ Fetch fallback packages """
     self.request.locator = MagicMock()
     version = "1.1"
     name = "foo"
     filename = "%s-%s.tar.gz" % (name, version)
     url = "https://pypi.org/pypi/%s/%s" % (name, filename)
     wheelname = "%s-%s.whl" % (name, version)
     wheel_url = "https://pypi.org/pypi/%s/%s" % (name, wheelname)
     dist = make_dist(url, name, version)
     wheel_dist = make_dist(wheel_url, name, version)
     self.request.locator.get_releases.return_value = [dist, wheel_dist]
     self.request.app_url = MagicMock()
     pkgs = get_fallback_packages(self.request, "foo", False)
     self.request.app_url.assert_any_call("api", "package", name, filename)
     self.request.app_url.assert_any_call("api", "package", name, wheelname)
     self.assertEqual(
         pkgs,
         {
             filename: {
                 "url": self.request.app_url(),
                 "requires_python": dist["requires_python"],
             },
             wheelname: {
                 "url": self.request.app_url(),
                 "requires_python": wheel_dist["requires_python"],
             },
         },
     )
Пример #5
0
 def test_fallback_packages(self):
     """ Fetch fallback packages """
     self.request.locator = MagicMock()
     version = "1.1"
     name = "foo"
     filename = "%s-%s.tar.gz" % (name, version)
     url = "https://pypi.org/pypi/%s/%s" % (name, filename)
     wheelname = "%s-%s.whl" % (name, version)
     wheel_url = "https://pypi.org/pypi/%s/%s" % (name, wheelname)
     dist = MagicMock()
     dist.name = name
     self.request.locator.get_project.return_value = {
         version: dist,
         "urls": {
             version: [url, wheel_url]
         },
     }
     self.request.app_url = MagicMock()
     pkgs = get_fallback_packages(self.request, "foo", False)
     self.request.app_url.assert_any_call("api", "package", name, filename)
     self.request.app_url.assert_any_call("api", "package", name, wheelname)
     self.assertEqual(
         pkgs,
         {
             filename: {
                 "url": self.request.app_url()
             },
             wheelname: {
                 "url": self.request.app_url()
             },
         },
     )
Пример #6
0
 def test_fallback_packages_redirect(self):
     """ Fetch fallback packages with redirect URLs """
     self.request.locator = MagicMock()
     version = "1.1"
     name = "foo"
     filename = "%s-%s.tar.gz" % (name, version)
     url = "http://pypi.python.org/pypi/%s/%s" % (name, filename)
     wheelname = "%s-%s.whl" % (name, version)
     wheel_url = "http://pypi.python.org/pypi/%s/%s" % (name, wheelname)
     dist = MagicMock()
     dist.name = name
     self.request.locator.get_project.return_value = {version: dist, "urls": {version: [url, wheel_url]}}
     pkgs = get_fallback_packages(self.request, "foo")
     self.assertEqual(pkgs, {filename: url, wheelname: wheel_url})
Пример #7
0
 def test_fallback_packages(self):
     """ Fetch fallback packages """
     self.request.locator = MagicMock()
     version = "1.1"
     name = "foo"
     filename = "%s-%s.tar.gz" % (name, version)
     url = "http://pypi.python.org/pypi/%s/%s" % (name, filename)
     wheelname = "%s-%s.whl" % (name, version)
     wheel_url = "http://pypi.python.org/pypi/%s/%s" % (name, wheelname)
     dist = MagicMock()
     dist.name = name
     self.request.locator.get_project.return_value = {version: dist, "urls": {version: [url, wheel_url]}}
     self.request.app_url = MagicMock()
     pkgs = get_fallback_packages(self.request, "foo", False)
     self.request.app_url.assert_any_call("api", "package", name, filename)
     self.request.app_url.assert_any_call("api", "package", name, wheelname)
     self.assertEqual(pkgs, {filename: self.request.app_url(), wheelname: self.request.app_url()})
Пример #8
0
 def test_disallow_fallback_packages(self):
     """Disallow fetch fallback packages"""
     self.request.locator = MagicMock()
     version = "1.1"
     name = "foo"
     filename = "%s-%s.tar.gz" % (name, version)
     url = "http://pypi.python.org/pypi/%s/%s" % (name, filename)
     wheelname = "%s-%s.whl" % (name, version)
     wheel_url = "http://pypi.python.org/pypi/%s/%s" % (name, wheelname)
     dist = MagicMock()
     dist.name = name
     self.request.locator.get_project.return_value = {
         version: dist,
         "urls": {version: [url, wheel_url]},
     }
     self.request.access.has_permission = MagicMock(return_value=False)
     pkgs = get_fallback_packages(self.request, "foo")
     self.assertEqual(pkgs, {})
Пример #9
0
 def test_fallback_packages_redirect(self):
     """ Fetch fallback packages with redirect URLs """
     self.request.locator = MagicMock()
     version = '1.1'
     name = 'foo'
     filename = '%s-%s.tar.gz' % (name, version)
     url = 'http://pypi.python.org/pypi/%s/%s' % (name, filename)
     dist = MagicMock()
     dist.name = name
     self.request.locator.get_project.return_value = {
         version: dist,
         'urls': {
             version: [url, 'this_should_never_be_used']
         }
     }
     pkgs = get_fallback_packages(self.request, 'foo')
     self.assertEqual(pkgs, {
         filename: url,
     })
Пример #10
0
 def test_fallback_packages_redirect(self):
     """ Fetch fallback packages with redirect URLs """
     self.request.locator = MagicMock()
     version = '1.1'
     name = 'foo'
     filename = '%s-%s.tar.gz' % (name, version)
     url = 'http://pypi.python.org/pypi/%s/%s' % (name, filename)
     dist = MagicMock()
     dist.name = name
     self.request.locator.get_project.return_value = {
         version: dist,
         'urls': {
             version: [url, 'this_should_never_be_used']
         }
     }
     pkgs = get_fallback_packages(self.request, 'foo')
     self.assertEqual(pkgs, {
         filename: url,
     })
Пример #11
0
 def test_fallback_packages(self):
     """ Fetch fallback packages """
     self.request.locator = MagicMock()
     version = '1.1'
     name = 'foo'
     filename = '%s-%s.tar.gz' % (name, version)
     url = 'http://pypi.python.org/pypi/%s/%s' % (name, filename)
     dist = MagicMock()
     dist.name = name
     self.request.locator.get_project.return_value = {
         version: dist,
         'urls': {
             version: [url, 'this_should_never_be_used']
         }
     }
     self.request.app_url = MagicMock()
     pkgs = get_fallback_packages(self.request, 'foo', False)
     self.request.app_url.assert_called_with('api', 'package', name, filename)
     self.assertEqual(pkgs, {
         filename: self.request.app_url(),
     })