From efc800a3bf9e2fd02acd53c4212ea61e09f03062 Mon Sep 17 00:00:00 2001 From: rachidatecs Date: Wed, 7 Jun 2023 14:26:44 -0400 Subject: [PATCH] Personalize the unit test to look for the 'in review' copy in th email's body --- src/registrar/tests/test_admin.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py index 35684ab00..19f16cfe0 100644 --- a/src/registrar/tests/test_admin.py +++ b/src/registrar/tests/test_admin.py @@ -107,14 +107,25 @@ class TestDomainApplicationAdmin(TestCase): # Use the model admin's save_model method model_admin.save_model(request, application, form=None, change=True) + + # Access the arguments passed to send_email + call_args = mock_client_instance.send_email.call_args + args, kwargs = call_args - # Assert that the email was sent + # Retrieve the email details from the arguments + from_email = kwargs.get("FromEmailAddress") + to_email = kwargs["Destination"]["ToAddresses"][0] + email_content = kwargs["Content"] + email_body = email_content['Simple']['Body']['Text']['Data'] - mock_client_instance.send_email.assert_called_once_with( - FromEmailAddress=settings.DEFAULT_FROM_EMAIL, - Destination={"ToAddresses": [EMAIL]}, - Content=ANY, - ) + # Assert or perform other checks on the email details + expected_string = "Your .gov domain request is being reviewed" + assert from_email == settings.DEFAULT_FROM_EMAIL + assert to_email == EMAIL + assert expected_string in email_body + + # Perform assertions on the mock call itself + mock_client_instance.send_email.assert_called_once() # Cleanup application.delete()