Exemple #1
0
    def test_upload_raises(self):
        from cheeseprism.views import upload

        context, request = self.base_cr
        request.POST["content"] = ""
        request.method = "POST"
        upload(context, request)
Exemple #2
0
 def test_upload_raises(self):
     from cheeseprism.views import upload
     context, request = self.base_cr
     request.POST['content'] = ''
     request.method = 'POST'
     with self.assertRaises(RuntimeError):
         upload(context, request)
Exemple #3
0
 def test_upload_raises(self):
     from cheeseprism.views import upload
     context, request = self.base_cr
     request.POST['content'] = ''
     request.method = 'POST'
     with self.assertRaises(RuntimeError):
         upload(context, request)
Exemple #4
0
    def test_upload_raises_packageadded(self):
        """
        If adding the package raises an error, an exception should be logged
        """
        from cheeseprism.views import upload

        self.setup_event()
        context, request = self.base_cr
        request.method = "POST"
        request.POST["content"] = FakeFS(path("dummypackage2/dist/dummypackage-0.1.tar.gz"))
        with patch("cheeseprism.views.event.PackageAdded", side_effect=RuntimeError("Kaboom")):
            with patch("path.path.write_bytes"):
                upload(context, request)
Exemple #5
0
 def test_upload_raises_packageadded(self):
     """
     If adding the package raises an error, an exception should be logged
     """
     from cheeseprism.views import upload
     self.setup_event()
     context, request = self.base_cr
     request.method = 'POST'
     request.POST['content'] = FakeFS(
         path('dummypackage2/dist/dummypackage-0.1.tar.gz'))
     with patch('cheeseprism.views.event.PackageAdded',
                side_effect=RuntimeError('Kaboom')):
         with patch('path.path.write_bytes'):
             upload(context, request)
Exemple #6
0
 def test_upload_raises_packageadded(self):
     """
     If adding the package raises an error, an exception should be logged
     """
     from cheeseprism.views import upload
     self.setup_event()
     context, request = self.base_cr
     request.method = 'POST'
     request.POST['content'] = FakeFS(path('dummypackage2/dist/dummypackage-0.1.tar.gz'))
     with patch('cheeseprism.views.event.PackageAdded',
                side_effect=RuntimeError('Kaboom')):
         with patch('path.path.write_bytes'):
             with self.assertRaises(RuntimeError):
                 upload(context, request)
Exemple #7
0
 def test_upload(self, sdist, wb):
     from cheeseprism.views import upload
     self.setup_event()
     context, request = self.base_cr
     request.method = 'POST'
     request.POST['content'] = FakeFS(path('dummypackage/dist/dummypackage-0.0dev.tar.gz'))
     res = upload(context, request)
     assert res.headers == {'X-Swalow-Status': 'SUCCESS'}
     assert 'fired' in self.event_results
Exemple #8
0
 def test_upload(self, wb):
     from cheeseprism.views import upload
     self.setup_event()
     context, request = self.base_cr
     request.method = 'POST'
     request.POST['content'] = FakeFS(path('dummypackage/dist/dummypackage-0.0dev.tar.gz'))
     with patch('cheeseprism.index.IndexManager.register_archive',
                return_value=(dict(name='dummycode', version='0.0dev'), '123')) as aa:
         res = upload(context, request)
         assert aa.called
     assert res.headers == {'X-Swalow-Status': 'SUCCESS'}
 def test_upload(self, wb):
     from cheeseprism.views import upload
     self.setup_event()
     context, request = self.base_cr
     request.method = 'POST'
     request.POST['content'] = FakeFS(
         path('dummypackage/dist/dummypackage-0.0dev.tar.gz'))
     with patch('cheeseprism.index.IndexManager.register_archive',
                return_value=(dict(name='dummycode',
                                   version='0.0dev'), '123')) as aa:
         res = upload(context, request)
         assert aa.called
     assert res.headers == {'X-Swalow-Status': 'SUCCESS'}
Exemple #10
0
 def test_upload(self, wb):
     from cheeseprism.views import upload
     self.setup_event()
     context, request = self.base_cr
     request.method = 'POST'
     request.POST['content'] = FakeFS(path('dummypackage/dist/dummypackage-0.0dev.tar.gz'))
     with patch('cheeseprism.index.IndexManager.pkginfo_from_file',
                return_value=stuf(name='dummycode', version='0.0dev')) as pkif:
         res = upload(context, request)
         assert pkif.called
         assert 'PackageAdded' in self.event_results
         assert self.event_results['PackageAdded'][0].name == pkif.return_value.name
     assert res.headers == {'X-Swalow-Status': 'SUCCESS'}
Exemple #11
0
    def test_upload(self, wb):
        from cheeseprism.views import upload

        self.setup_event()
        context, request = self.base_cr
        request.method = "POST"
        request.POST["content"] = FakeFS(path("dummypackage/dist/dummypackage-0.0dev.tar.gz"))
        with patch(
            "cheeseprism.index.IndexManager.pkginfo_from_file", return_value=stuf(name="dummycode", version="0.0dev")
        ) as pkif:
            res = upload(context, request)
            assert pkif.called
            assert "PackageAdded" in self.event_results
            assert self.event_results["PackageAdded"][0].name == pkif.return_value.name
        assert res.headers == {"X-Swalow-Status": "SUCCESS"}
Exemple #12
0
 def test_upload(self, wb):
     from cheeseprism.views import upload
     self.setup_event()
     context, request = self.base_cr
     request.method = 'POST'
     request.POST['content'] = FakeFS(
         path('dummypackage/dist/dummypackage-0.0dev.tar.gz'))
     with patch('cheeseprism.index.IndexManager.pkginfo_from_file',
                return_value=stuf(name='dummycode',
                                  version='0.0dev')) as pkif:
         res = upload(context, request)
         assert pkif.called
         assert 'PackageAdded' in self.event_results
         assert self.event_results['PackageAdded'][
             0].name == pkif.return_value.name
     assert res.headers == {'X-Swalow-Status': 'SUCCESS'}
Exemple #13
0
    def test_upload_w_rename(self):
        from cheeseprism.views import upload
        self.setup_event()
        context, request = self.base_cr

        request._namer = utils.strip_master
        request.method = 'POST'
        request.POST['content'] = FakeFS(path('mastertest-0.0-master.tar.gz'))

        def test_pkif(p, moe):
            assert p.basename() == 'mastertest-0.0.tar.gz'
            return stuf(name='mastertest', version='0.0-master')

        with patch('cheeseprism.index.IndexManager.pkginfo_from_file',
                   side_effect=test_pkif) as pkif:

            res = upload(context, request)
            assert pkif.called

        assert res.headers == {'X-Swalow-Status': 'SUCCESS'}
Exemple #14
0
    def test_upload_w_rename(self):
        from cheeseprism.views import upload
        self.setup_event()
        context, request = self.base_cr

        request._namer = utils.strip_master
        request.method = 'POST'
        request.POST['content'] = FakeFS(path('mastertest-0.0-master.tar.gz'))

        def test_pkif(p, moe):
            assert p.basename() == u'mastertest-0.0.tar.gz'
            return stuf(name='mastertest', version='0.0-master')

        with patch('cheeseprism.index.IndexManager.pkginfo_from_file',
                   side_effect=test_pkif) as pkif:

            res = upload(context, request)
            assert pkif.called

        assert res.headers == {'X-Swalow-Status': 'SUCCESS'}
Exemple #15
0
 def test_upload_raises(self):
     from cheeseprism.views import upload
     context, request = self.base_cr
     request.POST['content'] = ''
     request.method = 'POST'
     upload(context, request)
 def test_upload_raises(self):
     from cheeseprism.views import upload
     context, request = self.base_cr
     request.POST['content'] = ''
     request.method = 'POST'
     upload(context, request)