コード例 #1
0
ファイル: TestAwsClient.py プロジェクト: maniacs-oss/scar
 def test_delete_cloudwatch_group(self, mock_log_client):
     mock_log_client.return_value.delete_log_group.return_value = {
         'ResponseMetadata': {
             'RequestId': 'test_id',
             'HTTPStatusCode': 'code_42'
         },
         'ExtraData': 'test_extra'
     }
     result = Result()
     AwsClient().delete_cloudwatch_group('f1', result)
     self.assertEqual(mock_log_client.call_count, 1)
     self.assertTrue(call().delete_log_group(
         logGroupName='/aws/lambda/f1') in mock_log_client.mock_calls)
     self.assertEqual(result.plain_text,
                      "Log group 'f1' successfully deleted.\n")
     self.assertEqual(
         result.json, {
             'CloudWatchOutput': {
                 'RequestId': 'test_id',
                 'HTTPStatusCode': 'code_42'
             }
         })
     self.assertEqual(
         result.verbose, {
             'CloudWatchOutput': {
                 'ResponseMetadata': {
                     'RequestId': 'test_id',
                     'HTTPStatusCode': 'code_42'
                 },
                 'ExtraData': 'test_extra'
             }
         })
コード例 #2
0
ファイル: TestAwsClient.py プロジェクト: maniacs-oss/scar
 def test_delete_lambda_function(self, mock_lambda_client):
     mock_lambda_client.return_value.delete_function.return_value = {
         'ResponseMetadata': {
             'RequestId': 'test_id',
             'HTTPStatusCode': 'code_42'
         },
         'ExtraData': 'test_extra'
     }
     result = Result()
     AwsClient().delete_lambda_function('f1', result)
     self.assertEqual(mock_lambda_client.call_count, 1)
     self.assertTrue(call().delete_function(
         FunctionName='f1') in mock_lambda_client.mock_calls)
     self.assertEqual(result.plain_text,
                      "Function 'f1' successfully deleted.\n")
     self.assertEqual(result.json, {
         'LambdaOutput': {
             'RequestId': 'test_id',
             'HTTPStatusCode': 'code_42'
         }
     })
     self.assertEqual(
         result.verbose, {
             'LambdaOutput': {
                 'ResponseMetadata': {
                     'RequestId': 'test_id',
                     'HTTPStatusCode': 'code_42'
                 },
                 'ExtraData': 'test_extra'
             }
         })
コード例 #3
0
 def test_delete_cloudwatch_group_warning(self, mock_log_client):
     mock_log_client.side_effect = ClientError({'Error' : {'Code' : 'ResourceNotFoundException', 'Message' : 'test_message'}}, 'test2')
     result = Result()
     AwsClient().delete_cloudwatch_group('f1', result)
     self.assertEqual(result.plain_text, "Warning: Cannot delete log group '/aws/lambda/f1'. Group not found.\n")
     self.assertEqual(result.json, {'Warning': "Cannot delete log group '/aws/lambda/f1'. Group not found."})
     self.assertEqual(result.verbose, {'Warning': "Cannot delete log group '/aws/lambda/f1'. Group not found."})
コード例 #4
0
 def test_delete_resources(self, mock_result, mock_function_name, mock_delete_function, mock_delete_group):
     aux_result = Result()
     mock_result.return_value = aux_result
     AwsClient().delete_resources('f1', False, False)
     self.assertEqual(mock_function_name.call_count, 1)
     self.assertTrue(call('f1', False) in mock_function_name.mock_calls)
     self.assertEqual(mock_delete_function.call_count, 1)
     self.assertTrue(call('f1', aux_result) in mock_delete_function.mock_calls)
     self.assertEqual(mock_delete_group.call_count, 1)
     self.assertTrue(call('f1', aux_result) in mock_delete_group.mock_calls)
コード例 #5
0
ファイル: TestAwsClient.py プロジェクト: maniacs-oss/scar
 def test_delete_cloudwatch_group_error(self, mock_log_client):
     mock_log_client.side_effect = ClientError(
         {'Error': {
             'Code': '42',
             'Message': 'test_message'
         }}, 'test2')
     AwsClient().delete_cloudwatch_group('f1', Result())
     output = TestAwsClient.capturedOutput.getvalue()
     self.assertTrue("Error deleting the cloudwatch log:" in output)
     self.assertTrue(
         'An error occurred (42) when calling the test2 operation: test_message'
         in output)
コード例 #6
0
 def setUp(self):
     TestResult.result = Result()
     TestResult.capturedOutput = io.StringIO()
     sys.stdout = TestResult.capturedOutput