Skip to content

Commit dbdc8b6

Browse files
committed
update test to use REST API internal endpoint
1 parent 8d382d2 commit dbdc8b6

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

tests/aws/services/ses/test_ses.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,9 @@ def test_ses_sns_topic_integration_send_email_ses_destination(
937937
sender_email_address, recipient_email_address = setup_email_addresses()
938938
config_set_name = f"config-set-{short_uid()}"
939939

940-
EMAILS.clear()
940+
emails_url = config.internal_service_url() + EMAILS_ENDPOINT
941+
response = requests.delete(emails_url)
942+
assert response.status_code == 204
941943

942944
# create subscription to get notified about SES events
943945
topic_arn = sns_topic["Attributes"]["TopicArn"]
@@ -970,13 +972,19 @@ def test_ses_sns_topic_integration_send_email_ses_destination(
970972
}
971973
],
972974
)
973-
poll_condition(lambda: len(EMAILS) >= 4, timeout=3)
974-
assert EMAILS.pop(send_email["MessageId"])
975975

976+
def _get_emails():
977+
_resp = requests.get(emails_url)
978+
return _resp.json()["messages"]
979+
980+
poll_condition(lambda: len(_get_emails()) >= 4, timeout=3)
981+
requests.delete(emails_url, params={"id": send_email["MessageId"]})
982+
983+
emails = _get_emails()
976984
# we assert that we only received 3 emails
977-
assert len(EMAILS) == 3
985+
assert len(emails) == 3
978986

979-
emails = sorted(EMAILS.values(), key=lambda x: x["Body"]["text_part"])
987+
emails = sorted(emails, key=lambda x: x["Body"]["text_part"])
980988
# the first email is the validation of SNS confirming the SES subscription
981989
ses_delivery_notification = emails[1]
982990
ses_send_notification = emails[2]

0 commit comments

Comments
 (0)