Personalize the unit test to look for the 'in review' copy in th email's body

This commit is contained in:
rachidatecs 2023-06-07 14:26:44 -04:00
parent 31295053f9
commit efc800a3bf
No known key found for this signature in database
GPG key ID: 3CEBBFA7325E5525

View file

@ -108,13 +108,24 @@ class TestDomainApplicationAdmin(TestCase):
# Use the model admin's save_model method # Use the model admin's save_model method
model_admin.save_model(request, application, form=None, change=True) model_admin.save_model(request, application, form=None, change=True)
# Assert that the email was sent # Access the arguments passed to send_email
call_args = mock_client_instance.send_email.call_args
args, kwargs = call_args
mock_client_instance.send_email.assert_called_once_with( # Retrieve the email details from the arguments
FromEmailAddress=settings.DEFAULT_FROM_EMAIL, from_email = kwargs.get("FromEmailAddress")
Destination={"ToAddresses": [EMAIL]}, to_email = kwargs["Destination"]["ToAddresses"][0]
Content=ANY, email_content = kwargs["Content"]
) email_body = email_content['Simple']['Body']['Text']['Data']
# 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 # Cleanup
application.delete() application.delete()