예제 #1
0
 def testS3AssetstoreUpload(self):
     # Clear the assetstore database and create an S3 assetstore
     self.model('assetstore').remove(self.assetstore)
     params = {
         'name': 'S3 Assetstore',
         'bucket': 'bucketname',
         'prefix': 'testprefix',
         'accessKeyId': 'someKey',
         'secret': 'someSecret',
         'service': base.mockS3Server.service
     }
     assetstore = self.model('assetstore').createS3Assetstore(**params)
     self.assetstore = assetstore
     self._testUpload()
     # make an untracked upload to test that we can find and clear it
     conn = botoConnectS3(base.mockS3Server.botoConnect)
     bucket = conn.lookup(bucket_name='bucketname', validate=True)
     bucket.initiate_multipart_upload('testprefix/abandoned_upload')
     resp = self.request(path='/system/uploads',
                         method='GET',
                         user=self.admin)
     self.assertStatusOk(resp)
     self.assertEqual(len(resp.json), 1)
     # Ask to delete it
     resp = self.request(path='/system/uploads',
                         method='DELETE',
                         user=self.admin)
     self.assertStatusOk(resp)
     # Check that it is gone
     resp = self.request(path='/system/uploads',
                         method='GET',
                         user=self.admin)
     self.assertStatusOk(resp)
     self.assertEqual(resp.json, [])
예제 #2
0
 def testS3AssetstoreUpload(self):
     # Clear the assetstore database and create an S3 assetstore
     self.model('assetstore').remove(self.assetstore)
     params = {
         'name': 'S3 Assetstore',
         'bucket': 'bucketname',
         'prefix': 'testprefix',
         'accessKeyId': 'someKey',
         'secret': 'someSecret',
         'service': base.mockS3Server.service
     }
     assetstore = self.model('assetstore').createS3Assetstore(**params)
     self.assetstore = assetstore
     self._testUpload()
     # make an untracked upload to test that we can find and clear it
     conn = botoConnectS3(base.mockS3Server.botoConnect)
     bucket = conn.lookup(bucket_name='bucketname', validate=True)
     bucket.initiate_multipart_upload('testprefix/abandoned_upload')
     resp = self.request(path='/system/uploads', method='GET',
                         user=self.admin)
     self.assertStatusOk(resp)
     self.assertEqual(len(resp.json), 1)
     # Ask to delete it
     resp = self.request(path='/system/uploads', method='DELETE',
                         user=self.admin)
     self.assertStatusOk(resp)
     # Check that it is gone
     resp = self.request(path='/system/uploads', method='GET',
                         user=self.admin)
     self.assertStatusOk(resp)
     self.assertEqual(resp.json, [])
예제 #3
0
def createBucket(botoConnect, bucketName):
    """
    Create a bucket if it doesn't already exist.
    :param botoConnect: connection parameters to pass to use with boto.
    :type botoConnect: dict
    :param bucketName: the bucket name
    :type bucket: str
    :returns: a boto bucket.
    """
    conn = botoConnectS3(botoConnect)
    bucket = conn.lookup(bucket_name=bucketName, validate=True)
    # if found, return
    if bucket is not None:
        return
    bucket = conn.create_bucket(bucketName)
    # I would have preferred to set the CORS for the bucket we created, but
    # moto doesn't support that.
    # setBucketCors(bucket)
    return bucket
예제 #4
0
def createBucket(botoConnect, bucketName):
    """
    Create a bucket if it doesn't already exist.
    :param botoConnect: connection parameters to pass to use with boto.
    :type botoConnect: dict
    :param bucketName: the bucket name
    :type bucket: str
    :returns: a boto bucket.
    """
    conn = botoConnectS3(botoConnect)
    bucket = conn.lookup(bucket_name=bucketName, validate=True)
    # if found, return
    if bucket is not None:
        return
    bucket = conn.create_bucket(bucketName)
    # I would have preferred to set the CORS for the bucket we created, but
    # moto doesn't support that.
    # setBucketCors(bucket)
    return bucket