def test_get_s3_keys_success_one_key_with_suffix(self): self.client.put_object(Bucket=MY_BUCKET, Key='key3.txt', Body='awesome body') key = next(get_keys(self.client, MY_BUCKET, suffix='.txt')) self.assertEqual(key, 'key3.txt')
def test_get_s3_keys_success_one_key_with_prefix(self): self.client.put_object(Bucket=MY_BUCKET, Key='key3', Body='awesome body') keys = list(get_keys(self.client, MY_BUCKET, prefix=MY_PREFIX)) self.assertEqual(keys, [MY_PREFIX + '/key0', MY_PREFIX + '/key1'])
def test_get_s3_keys_failure_multi_pages(self): keys = get_keys(self.client, MY_BUCKET) _ = next(keys) _ = next(keys) with self.assertRaises(StopIteration): _ = next(keys)
def test_get_s3_keys_success_multi_pages(self): keys = get_keys(self.client, MY_BUCKET, MaxKeys=1) self.assertEqual(next(keys), MY_PREFIX + '/key0') self.assertEqual(next(keys), MY_PREFIX + '/key1')
def test_get_s3_keys_failure_one_key(self): with self.assertRaises(StopIteration): _ = next(get_keys(self.client, MY_BUCKET, prefix='foo'))
def test_get_s3_keys_success_one_key(self): key = next(get_keys(self.client, MY_BUCKET, MaxKeys=1)) self.assertEqual(key, MY_PREFIX + '/key0')