Exemple #1
0
    def test_die__calls_sns(self, mock_boto):

        mock_boto_client = MagicMock()
        mock_boto.return_value = mock_boto_client

        p = Processor(custom_config=self.TEST_CONFIG)

        with self.assertRaises(SystemExit):
            p.die()

        mock_boto_client.publish.assert_called_once()
        args, kwargs = mock_boto_client.publish.call_args
        self.assertIn('SoswWorkerErrors', kwargs['TopicArn'])
        self.assertEqual(kwargs['Subject'], 'Some Function died')
        self.assertEqual(kwargs['Message'], 'Unknown Failure')
Exemple #2
0
    def test_app_calls_get_config(self, mock_ssm):

        mock_ssm.return_value = {'mock': 'called'}
        os.environ['AWS_LAMBDA_FUNCTION_NAME'] = 'test_func'

        Processor(custom_config=self.TEST_CONFIG)
        mock_ssm.assert_called_once_with('test_func_config')
Exemple #3
0
    def test_app_init__with_some_clients(self, mock_boto_client):
        custom_config = {'init_clients': ['Sns', 'Siblings']}

        processor = Processor(custom_config=custom_config)
        self.assertIsInstance(
            getattr(processor, 'sns_client'), SnsManager,
            "SnsManager was not initialized. Probably boto3 sns instead of it."
        )
        self.assertIsNotNone(getattr(processor, 'siblings_client'))
Exemple #4
0
    def test_app_init__boto_and_components_custom_clients(
            self, mock_boto_client):
        custom_config = {'init_clients': ['dynamodb', 'Siblings']}

        processor = Processor(custom_config=custom_config)
        self.assertIsInstance(getattr(processor, 'siblings_client'),
                              SiblingsManager)

        # Clients of boto3 will not be exactly of same type (something dynamic in boto3), so we can't compare classes.
        # Let us assume that checking the class_name is enough for this test.
        self.assertEqual(str(type(getattr(processor, 'dynamodb_client'))),
                         str(type(boto3.client('dynamodb'))))
Exemple #5
0
 def test_app_init__with_some_invalid_client(self, mock_boto_client):
     custom_config = {
         'init_clients': ['NotExists']
     }
     Processor(custom_config=custom_config)
     mock_boto_client.assert_called_with('not_exists')
Exemple #6
0
 def test_app_init(self, mock_boto_client):
     Processor(custom_config=self.TEST_CONFIG)
     self.assertTrue(True)
Exemple #7
0
    def test_die(self, mock_boto):

        p = Processor(custom_config=self.TEST_CONFIG)

        with self.assertRaises(SystemExit):
            p.die()