示例#1
0
 def test_package_httperror(self, pd):
     """
     package: test catching httperror
     """
     request = self.package_request(pd)
     with patch('requests.get') as get:
         from cheeseprism import views; reload(views)
         get.side_effect = views.HTTPError('http://boto', 500, 'KABOOM', dict(), None)
         out = views.package(request)
     assert isinstance(out, HTTPFound)
示例#2
0
 def test_package_urlerror(self, pd):
     """
     package: test catching urlerror
     """
     request = self.package_request(pd)
     with patch('requests.get') as get:
         from cheeseprism import views; reload(views)
         get.side_effect = views.URLError('kaboom')
         out = views.package(request)
     assert isinstance(out, HTTPFound)
     assert out.location == '/find-packages'
示例#3
0
 def test_package_no_details(self, pd):
     """
     pypi doesn't know anything about our package
     """
     from cheeseprism.views import package
     pd.return_value = None
     request = testing.DummyRequest()
     request.matchdict.update(dict(name='boto', version='1.2.3'))
     out = package(request)
     assert isinstance(out, HTTPFound)
     assert out.location == '/find-packages'
示例#4
0
 def test_package_no_details(self, pd):
     """
     pypi doesn't know anything about our package
     """
     from cheeseprism.views import package
     pd.return_value = None
     request = testing.DummyRequest()
     request.matchdict.update(dict(name='boto',
                                   version='1.2.3'))
     out = package(request)
     assert isinstance(out, HTTPFound)
     assert out.location == '/find-packages'
示例#5
0
 def test_package_urlerror(self, pd):
     """
     package: test catching urlerror
     """
     request = self.package_request(pd)
     with patch('requests.get') as get:
         from cheeseprism import views
         reload(views)
         get.side_effect = views.URLError('kaboom')
         out = views.package(request)
     assert isinstance(out, HTTPFound)
     assert out.location == '/find-packages'
示例#6
0
 def test_package_httperror(self, pd):
     """
     package: test catching httperror
     """
     request = self.package_request(pd)
     with patch('requests.get') as get:
         from cheeseprism import views
         reload(views)
         get.side_effect = views.HTTPError('http://boto', 500, 'KABOOM',
                                           dict(), None)
         out = views.package(request)
     assert isinstance(out, HTTPFound)
示例#7
0
    def test_package_httperror(self, pd):
        """
        from_pypi: test catching httperror
        """
        request = self.package_request(pd)
        with patch("requests.get") as get:
            from cheeseprism import views

            reload(views)
            get.side_effect = views.HTTPError("http://boto", 500, "KABOOM", dict(), None)
            out = views.package(request)
        assert isinstance(out, HTTPFound)
示例#8
0
 def test_package_good(self, pd):
     """
     from_pypi: test catching urlerror
     """
     request = self.package_request(pd)
     with patch('requests.get') as get:
         resp = get.return_value = Mock('response')
         resp.content = PipExtBase.dists['dp'].bytes()
         from cheeseprism import views; reload(views)
         out = views.package(request)
     assert isinstance(out, HTTPFound)
     assert out.location == '/index/boto'
示例#9
0
 def test_package_md5_matches(self, pd):
     """
     package is already in index
     """
     from cheeseprism.views import package
     td = dict(name='boto', version='1.2.3', md5_digest='12345')
     pd.return_value = [td]
     request = CPDummyRequest()
     request.matchdict.update(td)
     request.index_data.update({'12345': True})
     out = package(request)
     assert isinstance(out, HTTPFound)
     assert out.location == '/index/boto'
示例#10
0
 def test_package_good(self, pd):
     """
     from_pypi: test catching urlerror
     """
     request = self.package_request(pd)
     with patch('requests.get') as get:
         resp = get.return_value = Mock('response')
         resp.content = PipExtBase.dists['dp'].bytes()
         from cheeseprism import views
         reload(views)
         out = views.package(request)
     assert isinstance(out, HTTPFound)
     assert out.location == '/index/boto'
示例#11
0
 def test_package_downloads_ok_but_bad(self, pd):
     """
     from_pypi: test catching urlerror
     """
     request = self.package_request(pd)
     with patch('requests.get') as get:
         resp = get.return_value = Mock('response')
         resp.content = PipExtBase.dists['dp'].bytes()
         from cheeseprism import views; reload(views)
         with patch('cheeseprism.index.IndexManager.pkginfo_from_file') as pkff:
             pkff.side_effect = ValueError("KABOOM")
             out = views.package(request)
     assert isinstance(out, HTTPFound)
     assert out.location == '/find-packages'
示例#12
0
 def test_package_md5_matches(self, pd):
     """
     package is already in index
     """
     from cheeseprism.views import package
     td = dict(name='boto',
               version='1.2.3',
               md5_digest='12345')
     pd.return_value = [td]        
     request = CPDummyRequest()
     request.matchdict.update(td)
     request.index_data.update({'12345':True})
     out = package(request)
     assert isinstance(out, HTTPFound)
     assert out.location == '/index/boto'
示例#13
0
    def test_package_good(self, pd):
        """
        from_pypi: test catching urlerror
        """
        request = self.package_request(pd)
        request.file_root.mkdir()
        with patch("requests.get") as get:
            resp = get.return_value = Mock("response")
            resp.content = PipExtBase.dists["dp"].bytes()
            from cheeseprism import views

            reload(views)
            out = views.package(request)
        assert isinstance(out, HTTPFound)
        assert out.location == "/index/boto"
示例#14
0
 def test_package_downloads_ok_but_bad(self, pd):
     """
     from_pypi: test catching urlerror
     """
     request = self.package_request(pd)
     with patch('requests.get') as get:
         resp = get.return_value = Mock('response')
         resp.content = PipExtBase.dists['dp'].bytes()
         from cheeseprism import views
         reload(views)
         with patch('cheeseprism.index.IndexManager.pkginfo_from_file'
                    ) as pkff:
             pkff.side_effect = ValueError("KABOOM")
             out = views.package(request)
     assert isinstance(out, HTTPFound)
     assert out.location == '/find-packages'