Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GavinZZ committed Sep 28, 2023
1 parent 851346f commit c7a2a21
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tests/model/eventsources/test_sns_event_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ def setUp(self):
self.function.get_passthrough_resource_attributes = Mock()
self.function.get_passthrough_resource_attributes.return_value = {}

self.kwargs = {"function": self.function, "intrinsics_resolver": Mock()}

def test_to_cloudformation_returns_permission_and_subscription_resources(self):
resources = self.sns_event_source.to_cloudformation(function=self.function)
resources = self.sns_event_source.to_cloudformation(**self.kwargs)
self.assertEqual(len(resources), 2)
self.assertEqual(resources[0].resource_type, "AWS::Lambda::Permission")
self.assertEqual(resources[1].resource_type, "AWS::SNS::Subscription")
Expand All @@ -37,7 +39,7 @@ def test_to_cloudformation_passes_the_region(self):
region = "us-west-2"
self.sns_event_source.Region = region

resources = self.sns_event_source.to_cloudformation(function=self.function)
resources = self.sns_event_source.to_cloudformation(**self.kwargs)
self.assertEqual(len(resources), 2)
self.assertEqual(resources[1].resource_type, "AWS::SNS::Subscription")
subscription = resources[1]
Expand All @@ -51,7 +53,7 @@ def test_to_cloudformation_passes_the_filter_policy(self):
}
self.sns_event_source.FilterPolicy = filterPolicy

resources = self.sns_event_source.to_cloudformation(function=self.function)
resources = self.sns_event_source.to_cloudformation(**self.kwargs)
self.assertEqual(len(resources), 2)
self.assertEqual(resources[1].resource_type, "AWS::SNS::Subscription")
subscription = resources[1]
Expand All @@ -61,7 +63,7 @@ def test_to_cloudformation_passes_the_filter_policy_scope(self):
filterPolicyScope = "MessageAttributes"
self.sns_event_source.FilterPolicyScope = filterPolicyScope

resources = self.sns_event_source.to_cloudformation(function=self.function)
resources = self.sns_event_source.to_cloudformation(**self.kwargs)
self.assertEqual(len(resources), 2)
self.assertEqual(resources[1].resource_type, "AWS::SNS::Subscription")
subscription = resources[1]
Expand All @@ -71,7 +73,7 @@ def test_to_cloudformation_passes_the_redrive_policy(self):
redrive_policy = {"deadLetterTargetArn": "arn:aws:sqs:us-east-2:123456789012:MyDeadLetterQueue"}
self.sns_event_source.RedrivePolicy = redrive_policy

resources = self.sns_event_source.to_cloudformation(function=self.function)
resources = self.sns_event_source.to_cloudformation(**self.kwargs)
self.assertEqual(len(resources), 2)
self.assertEqual(resources[1].resource_type, "AWS::SNS::Subscription")
subscription = resources[1]
Expand All @@ -89,7 +91,7 @@ def test_to_cloudformation_when_sqs_subscription_disable(self):
sqsSubscription = False
self.sns_event_source.SqsSubscription = sqsSubscription

resources = self.sns_event_source.to_cloudformation(function=self.function)
resources = self.sns_event_source.to_cloudformation(**self.kwargs)
self.assertEqual(len(resources), 2)
self.assertEqual(resources[0].resource_type, "AWS::Lambda::Permission")
self.assertEqual(resources[1].resource_type, "AWS::SNS::Subscription")
Expand Down

0 comments on commit c7a2a21

Please sign in to comment.