Exemple #1
0
 def test_setup_resources(self):
     my_handler = S3Handler(aws_access_key_id='access_key',
                            aws_secret_access_key='secret_key',
                            aws_region_name='us-west-1')
     self.assertEqual(my_handler.aws_access_key_id, 'access_key')
     self.assertEqual(my_handler.aws_secret_access_key, 'secret_key')
     self.assertEqual(my_handler.aws_region_name, 'us-west-1')
Exemple #2
0
 def pre_convert_s3_handler(cls):
     if not cls._pre_convert_s3_handler:
         cls._pre_convert_s3_handler = S3Handler(
             bucket_name=cls.pre_convert_bucket,
             aws_access_key_id=cls.aws_access_key_id,
             aws_secret_access_key=cls.aws_secret_access_key,
             aws_region_name=cls.aws_region_name)
     return cls._pre_convert_s3_handler
Exemple #3
0
 def door43_s3_handler(cls):
     if not cls._door43_s3_handler:
         cls._door43_s3_handler = S3Handler(
             bucket_name=cls.door43_bucket,
             aws_access_key_id=cls.aws_access_key_id,
             aws_secret_access_key=cls.aws_secret_access_key,
             aws_region_name=cls.aws_region_name)
     return cls._door43_s3_handler
Exemple #4
0
 def test_create_bucket(self):
     handler = S3Handler()
     bucket_name = "my_test_bucket"
     handler.create_bucket(bucket_name)
     try:
         handler.resource.meta.client.head_bucket(Bucket=bucket_name)
     except ClientError:
         self.fail("Was not able to create bucket!")
Exemple #5
0
 def test_put_contents(self):
     bucket_name = "my_test_bucket"
     handler = S3Handler(bucket_name)
     handler.create_bucket()
     key = "contents/goes/here"
     contents = "This is a test"
     handler.put_contents(key, contents)
     file_contents = handler.get_file_contents(key)
     self.assertEqual(file_contents, contents)
Exemple #6
0
 def setUp(self):
     """Runs before each test."""
     self.temp_dir = tempfile.mkdtemp(prefix='s3HandlerTest_')
     self.handler = S3Handler(bucket_name=self.MOCK_BUCKET_NAME)
     self.handler.create_bucket()