@@ -937,7 +937,9 @@ def test_ses_sns_topic_integration_send_email_ses_destination(
937
937
sender_email_address , recipient_email_address = setup_email_addresses ()
938
938
config_set_name = f"config-set-{ short_uid ()} "
939
939
940
- EMAILS .clear ()
940
+ emails_url = config .internal_service_url () + EMAILS_ENDPOINT
941
+ response = requests .delete (emails_url )
942
+ assert response .status_code == 204
941
943
942
944
# create subscription to get notified about SES events
943
945
topic_arn = sns_topic ["Attributes" ]["TopicArn" ]
@@ -970,13 +972,19 @@ def test_ses_sns_topic_integration_send_email_ses_destination(
970
972
}
971
973
],
972
974
)
973
- poll_condition (lambda : len (EMAILS ) >= 4 , timeout = 3 )
974
- assert EMAILS .pop (send_email ["MessageId" ])
975
975
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 ()
976
984
# we assert that we only received 3 emails
977
- assert len (EMAILS ) == 3
985
+ assert len (emails ) == 3
978
986
979
- emails = sorted (EMAILS . values () , key = lambda x : x ["Body" ]["text_part" ])
987
+ emails = sorted (emails , key = lambda x : x ["Body" ]["text_part" ])
980
988
# the first email is the validation of SNS confirming the SES subscription
981
989
ses_delivery_notification = emails [1 ]
982
990
ses_send_notification = emails [2 ]
0 commit comments