示例#1
0
 def test_add_s3_bucket_folder(self, mock_s3_client):
     aws_client = AwsClient()
     aws_client.add_s3_bucket_folder('test_bucket', 'input/')
     aws_client.add_s3_bucket_folder('test_bucket', 'output/')
     self.assertEqual(mock_s3_client.call_count, 2)
     self.assertTrue(call().put_object(Bucket='test_bucket', Key="input/") in mock_s3_client.mock_calls)
     self.assertTrue(call().put_object(Bucket='test_bucket', Key="output/") in mock_s3_client.mock_calls)         
示例#2
0
 def test_add_s3_bucket_folder_error(self, mock_s3_client):
     mock_s3_client.side_effect = ClientError({'Error' : {'Code' : '42', 'Message' : 'test_message'}}, 'test2')
     aws_client = AwsClient()
     with self.assertRaises(ClientError):        
         aws_client.add_s3_bucket_folder('test_bucket', 'input/')
         aws_client.add_s3_bucket_folder('test_bucket', 'output/')
     output = TestAwsClient.capturedOutput.getvalue()
     self.assertTrue("Error creating the S3 bucket 'test_bucket' folders:" in output)
     self.assertTrue('An error occurred (42) when calling the test2 operation: test_message' in output)