def test_delete_image_from_s3(self, s3_client, organization_with_image): uploader = S3Uploader(u'group') storage_path = S3Uploader.get_storage_path(u'group') key = os.path.join(storage_path, organization_with_image[u'image_url']) # key must exist assert s3_client.head_object(Bucket=self.bucket_name, Key=key) uploader.delete(organization_with_image[u'image_url']) # key shouldn't exist, this raises ClientError with pytest.raises(ClientError): s3_client.head_object(Bucket=self.bucket_name, Key=key)
def test_clean_dict(self): '''S3Uploader retrieves bucket as expected''' uploader = S3Uploader('') date_dict = {'key': datetime.datetime(1970, 1, 2, 3, 4, 5, 6)} clean_dict = uploader.as_clean_dict(date_dict) assert_equal(clean_dict['key'], '1970-01-02T03:04:05.000006')
def test_get_bucket(self): '''S3Uploader retrieves bucket as expected''' uploader = S3Uploader('') assert_true(uploader.get_s3_bucket(BUCKET_NAME))