Esempio n. 1
0
 def test_bucket_load_encounters_other_exception(self):
     self.client.list_buckets.side_effect = ClientError(
         {'Error':
          {'Code': 'ExpiredToken',
           'Message': 'The provided token has expired.'}},
         'ListBuckets')
     with self.assertRaises(ClientError):
         inject.bucket_load(self.resource)
Esempio n. 2
0
 def test_bucket_load_encounters_access_exception(self):
     self.client.list_buckets.side_effect = ClientError(
         {'Error':
          {'Code': 'AccessDenied',
           'Message': 'Access Denied'}},
         'ListBuckets')
     inject.bucket_load(self.resource)
     self.assertEqual(self.resource.meta.data, {})
Esempio n. 3
0
 def test_bucket_load_doesnt_find_bucket(self):
     self.resource.name = 'MyBucket'
     self.client.list_buckets.return_value = {
         'Buckets': [
             {'Name': 'NotMyBucket', 'CreationDate': 1},
             {'Name': 'NotMine2', 'CreationDate': 2},
         ],
     }
     inject.bucket_load(self.resource)
     self.assertEqual(self.resource.meta.data, {})
Esempio n. 4
0
 def test_bucket_load_raise_error(self):
     self.resource.name = 'MyBucket'
     self.client.list_buckets.return_value = {
         'Buckets': [
             {
                 'Name': 'NotMyBucket',
                 'CreationDate': 1
             },
             {
                 'Name': 'NotMine2',
                 'CreationDate': 2
             },
         ],
     }
     with self.assertRaises(ClientError):
         inject.bucket_load(self.resource)
Esempio n. 5
0
    def test_bucket_load_finds_bucket(self):
        self.resource.name = 'MyBucket'
        self.client.list_buckets.return_value = {
            'Buckets': [
                {
                    'Name': 'NotMyBucket',
                    'CreationDate': 1
                },
                {
                    'Name': self.resource.name,
                    'CreationDate': 2
                },
            ],
        }

        inject.bucket_load(self.resource)
        assert self.resource.meta.data == {
            'Name': self.resource.name,
            'CreationDate': 2,
        }