8000 use snapshots for SNS tests by bentsku · Pull Request #6601 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

use snapshots for SNS tests #6601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix change
  • Loading branch information
bentsku committed Aug 9, 2022
commit 41d4935c8736a4834c334b01f98e2f3c4d2fb2b6
12 changes: 9 additions & 3 deletions tests/integration/test_sns.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ def sns_snapshot_transformer(snapshot):
snapshot.add_transformer(snapshot.transform.sns_api())


def _order_dict(response: dict) -> dict:
return {
key: _order_dict(val) if isinstance(val, dict) else val
for key, val in sorted(response.items(), key=itemgetter(0))
}


class TestSNSSubscription:
@pytest.mark.aws_validated
def test_python_lambda_subscribe_sns_topic(
Expand Down Expand Up @@ -840,8 +847,7 @@ def test_redrive_policy_lambda_subscription(
SubscriptionArn=subscription["SubscriptionArn"]
)
# todo: hacky fix for snapshot resource replacement

snapshot.match("subscription-attributes", response_attributes)
snapshot.match("subscription-attributes", _order_dict(response_attributes))

lambda_client.delete_function(FunctionName=lambda_name)

Expand All @@ -857,7 +863,7 @@ def test_redrive_policy_lambda_subscription(
), f"invalid number of messages in DLQ response {response}"
message = json.loads(response["Messages"][0]["Body"])
assert message["Type"] == "Notification"
assert json.loads(message["Message"])["message"] == "test_redrive_policy"
assert message["Message"] == "test_redrive_policy"

@pytest.mark.aws_validated
def test_publish_with_empty_subject(self, sns_client, sns_create_topic):
Expand Down
20 changes: 10 additions & 10 deletions tests/integration/test_sns.snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -724,21 +724,21 @@
}
},
"tests/integration/test_sns.py::TestSNSProvider::test_redrive_policy_lambda_subscription": {
"recorded-date": "04-08-2022, 16:22:25",
"recorded-date": "04-08-2022, 17:05:46",
"recorded-content": {
"subscription-attributes": {
"Attributes": {
"ConfirmationWasAuthenticated": "true",
"Endpoint": "arn:aws:lambda:<region>:111111111111:function:<resource:1>",
"Owner": "111111111111",
"PendingConfirmation": "false",
"Protocol": "lambda",
"RawMessageDelivery": "false",
"TopicArn": "arn:aws:sns:<region>:111111111111:<resource:1>",
"Endpoint": "arn:aws:lambda:<region>:111111111111:function:<resource:2>",
"RedrivePolicy": {
"deadLetterTargetArn": "arn:aws:sqs:<region>:111111111111:<resource:3>"
"deadLetterTargetArn": "arn:aws:sqs:<region>:111111111111:<resource:2>"
},
"Protocol": "lambda",
"PendingConfirmation": "false",
"ConfirmationWasAuthenticated": "true",
"SubscriptionArn": "arn:aws:sns:<region>:111111111111:<resource:1>:<resource:4>"
"SubscriptionArn": "arn:aws:sns:<region>:111111111111:<resource:4>:<resource:3>",
"TopicArn": "arn:aws:sns:<region>:111111111111:<resource:4>"
},
"ResponseMetadata": {
"HTTPHeaders": {},
Expand All @@ -754,13 +754,13 @@
"Body": {
"Type": "Notification",
"MessageId": "<uuid:2>",
"TopicArn": "arn:aws:sns:<region>:111111111111:<resource:1>",
"TopicArn": "arn:aws:sns:<region>:111111111111:<resource:4>",
"Message": "test_redrive_policy",
"Timestamp": "date",
"SignatureVersion": "1",
"Signature": "<signature>",
"SigningCertURL": "https://sns.<region>.amazonaws.com/SimpleNotificationService-<signing-cert-file:1>.pem",
"UnsubscribeURL": "<unsubscribe-domain>/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:<region>:111111111111:<resource:1>:<resource:4>"
"UnsubscribeURL": "<unsubscribe-domain>/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:<region>:111111111111:<resource:4>:<resource:3>"
}
}
],
Expand Down
0