Example #1
0
    def post(self):
        try:
            action = self.request.params[':action']
        except KeyError:
            return self.abort(400, detail=":action field not found")

        if action != "file_upload":
            raise self.abort(400, detail="action not supported: %s" % action)

        try:
            content = self.request.params['content']
        except KeyError:
            raise self.abort(400, detail="content file field not found")

        if "/" in content.filename:
            raise self.abort(400, detail="bad filename")

        if not config.overwrite and package_api.exists(config.bucket,
                                                       content.filename):
            raise self.abort(409, detail="file already exists")

        package_api.write(config.bucket, content.filename, content.value)
        self.response.write("")
Example #2
0
    def post(self):
        try:
            action = self.request.params[':action']
        except KeyError:
            return self.abort(400, detail=":action field not found")

        if action != "file_upload":
            raise self.abort(400, detail="action not supported: %s" % action)

        try:
            content = self.request.params['content']
        except KeyError:
            raise self.abort(400, detail="content file field not found")

        if "/" in content.filename:
            raise self.abort(400, detail="bad filename")

        if not config.overwrite and package_api.exists(config.bucket,
                                                       content.filename):
            raise self.abort(409, detail="file already exists")

        package_api.write(config.bucket, content.filename, content.value)
        self.response.write("")
 def test_returns_False_if_not_exists(self):
     with mock.patch('cloudstorage.stat') as stat_method:
         stat_method.side_effect = cloudstorage.NotFoundError
         self.assertFalse(exists('packages', 'not-a-package.tar.bz2'))
 def test_returns_True_if_exists(self):
     with mock.patch('cloudstorage.stat') as stat_method:
         stat_method.return_value = True
         self.assertTrue(exists('packages', 'pytz-2012b.tar.bz2'))
Example #5
0
 def test_returns_False_if_not_exists(self):
     with mock.patch('cloudstorage.stat') as stat_method:
         stat_method.side_effect = cloudstorage.NotFoundError
         self.assertFalse(exists('packages', 'not-a-package.tar.bz2'))
Example #6
0
 def test_returns_True_if_exists(self):
     with mock.patch('cloudstorage.stat') as stat_method:
         stat_method.return_value = True
         self.assertTrue(exists('packages', 'pytz-2012b.tar.bz2'))