mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-18 10:29:23 +02:00
Refactor email tests to deprecate submitter
This commit is contained in:
parent
2fcad733cd
commit
a9ab882866
3 changed files with 27 additions and 18 deletions
|
@ -648,7 +648,9 @@ class TestDomainRequestAdmin(MockEppLib):
|
||||||
already_has_domains = DomainRequest.ActionNeededReasons.ALREADY_HAS_DOMAINS
|
already_has_domains = DomainRequest.ActionNeededReasons.ALREADY_HAS_DOMAINS
|
||||||
self.transition_state_and_send_email(domain_request, action_needed, action_needed_reason=already_has_domains)
|
self.transition_state_and_send_email(domain_request, action_needed, action_needed_reason=already_has_domains)
|
||||||
|
|
||||||
self.assert_email_is_accurate("ORGANIZATION ALREADY HAS A .GOV DOMAIN", 0, _creator.email, bcc_email_address=BCC_EMAIL)
|
self.assert_email_is_accurate(
|
||||||
|
"ORGANIZATION ALREADY HAS A .GOV DOMAIN", 0, _creator.email, bcc_email_address=BCC_EMAIL
|
||||||
|
)
|
||||||
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
|
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
|
||||||
|
|
||||||
# Test the email sent out for bad_name
|
# Test the email sent out for bad_name
|
||||||
|
@ -716,7 +718,9 @@ class TestDomainRequestAdmin(MockEppLib):
|
||||||
action_needed_reason=eligibility_unclear,
|
action_needed_reason=eligibility_unclear,
|
||||||
action_needed_reason_email="custom content when starting anew",
|
action_needed_reason_email="custom content when starting anew",
|
||||||
)
|
)
|
||||||
self.assert_email_is_accurate("custom content when starting anew", 5, _creator.email, bcc_email_address=BCC_EMAIL)
|
self.assert_email_is_accurate(
|
||||||
|
"custom content when starting anew", 5, _creator.email, bcc_email_address=BCC_EMAIL
|
||||||
|
)
|
||||||
self.assertEqual(len(self.mock_client.EMAILS_SENT), 6)
|
self.assertEqual(len(self.mock_client.EMAILS_SENT), 6)
|
||||||
|
|
||||||
# def test_action_needed_sends_reason_email_prod_bcc(self):
|
# def test_action_needed_sends_reason_email_prod_bcc(self):
|
||||||
|
@ -1046,7 +1050,9 @@ class TestDomainRequestAdmin(MockEppLib):
|
||||||
DomainRequest.DomainRequestStatus.REJECTED,
|
DomainRequest.DomainRequestStatus.REJECTED,
|
||||||
DomainRequest.RejectionReasons.SECOND_DOMAIN_REASONING,
|
DomainRequest.RejectionReasons.SECOND_DOMAIN_REASONING,
|
||||||
)
|
)
|
||||||
self.assert_email_is_accurate("Your domain request was rejected because Testorg has a .gov domain.", 0, _creator.email)
|
self.assert_email_is_accurate(
|
||||||
|
"Your domain request was rejected because Testorg has a .gov domain.", 0, _creator.email
|
||||||
|
)
|
||||||
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
|
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
|
||||||
|
|
||||||
# Approve
|
# Approve
|
||||||
|
|
|
@ -111,9 +111,7 @@ class TestEmails(TestCase):
|
||||||
_, kwargs = self.mock_client.send_email.call_args
|
_, kwargs = self.mock_client.send_email.call_args
|
||||||
body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"]
|
body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"]
|
||||||
self.assertIn("Other employees from your organization:", body)
|
self.assertIn("Other employees from your organization:", body)
|
||||||
# spacing should be right between adjacent elements
|
# spacing should be right between adjacent elements self.assertRegex(body, r"5557\n\nAnything else")
|
||||||
self.assertRegex(body, r"5556\n\nOther employees")
|
|
||||||
self.assertRegex(body, r"5557\n\nAnything else")
|
|
||||||
|
|
||||||
@boto3_mocking.patching
|
@boto3_mocking.patching
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
|
@ -125,7 +123,6 @@ class TestEmails(TestCase):
|
||||||
_, kwargs = self.mock_client.send_email.call_args
|
_, kwargs = self.mock_client.send_email.call_args
|
||||||
body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"]
|
body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"]
|
||||||
# spacing should be right between adjacent elements
|
# spacing should be right between adjacent elements
|
||||||
self.assertRegex(body, r"5556\n\nOther employees")
|
|
||||||
self.assertRegex(body, r"None\n\nAnything else")
|
self.assertRegex(body, r"None\n\nAnything else")
|
||||||
|
|
||||||
@boto3_mocking.patching
|
@boto3_mocking.patching
|
||||||
|
|
|
@ -257,7 +257,9 @@ class TestDomainRequest(TestCase):
|
||||||
def test_submit_from_started_sends_email(self):
|
def test_submit_from_started_sends_email(self):
|
||||||
msg = "Create a domain request and submit it and see if email was sent."
|
msg = "Create a domain request and submit it and see if email was sent."
|
||||||
domain_request = completed_domain_request(user=self.dummy_user_2)
|
domain_request = completed_domain_request(user=self.dummy_user_2)
|
||||||
self.check_email_sent(domain_request, msg, "submit", 1, expected_content="Hello")
|
self.check_email_sent(
|
||||||
|
domain_request, msg, "submit", 1, expected_content="Hi", expected_email=self.dummy_user_2.email
|
||||||
|
)
|
||||||
|
|
||||||
@override_flag("profile_feature", active=True)
|
@override_flag("profile_feature", active=True)
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
|
@ -272,10 +274,9 @@ class TestDomainRequest(TestCase):
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_submit_from_withdrawn_sends_email(self):
|
def test_submit_from_withdrawn_sends_email(self):
|
||||||
msg = "Create a withdrawn domain request and submit it and see if email was sent."
|
msg = "Create a withdrawn domain request and submit it and see if email was sent."
|
||||||
domain_request = completed_domain_request(
|
user, _ = User.objects.get_or_create(username="testy")
|
||||||
status=DomainRequest.DomainRequestStatus.WITHDRAWN
|
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.WITHDRAWN, user=user)
|
||||||
)
|
self.check_email_sent(domain_request, msg, "submit", 1, expected_content="Hi", expected_email=user.email)
|
||||||
self.check_email_sent(domain_request, msg, "submit", 1, expected_content="Hello")
|
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_submit_from_action_needed_does_not_send_email(self):
|
def test_submit_from_action_needed_does_not_send_email(self):
|
||||||
|
@ -292,20 +293,25 @@ class TestDomainRequest(TestCase):
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_approve_sends_email(self):
|
def test_approve_sends_email(self):
|
||||||
msg = "Create a domain request and approve it and see if email was sent."
|
msg = "Create a domain request and approve it and see if email was sent."
|
||||||
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
|
user, _ = User.objects.get_or_create(username="testy")
|
||||||
self.check_email_sent(domain_request, msg, "approve", 1, expected_content="Hello")
|
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW, user=user)
|
||||||
|
self.check_email_sent(domain_request, msg, "approve", 1, expected_content="approved", expected_email=user.email)
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_withdraw_sends_email(self):
|
def test_withdraw_sends_email(self):
|
||||||
msg = "Create a domain request and withdraw it and see if email was sent."
|
msg = "Create a domain request and withdraw it and see if email was sent."
|
||||||
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
|
user, _ = User.objects.get_or_create(username="testy")
|
||||||
self.check_email_sent(domain_request, msg, "withdraw", 1, expected_content="Hello")
|
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW, user=user)
|
||||||
|
self.check_email_sent(
|
||||||
|
domain_request, msg, "withdraw", 1, expected_content="withdrawn", expected_email=user.email
|
||||||
|
)
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_reject_sends_email(self):
|
def test_reject_sends_email(self):
|
||||||
msg = "Create a domain request and reject it and see if email was sent."
|
msg = "Create a domain request and reject it and see if email was sent."
|
||||||
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.APPROVED)
|
user, _ = User.objects.get_or_create(username="testy")
|
||||||
self.check_email_sent(domain_request, msg, "reject", 1, expected_content="Hello")
|
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.APPROVED, user=user)
|
||||||
|
self.check_email_sent(domain_request, msg, "reject", 1, expected_content="rejected", expected_email=user.email)
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_reject_with_prejudice_does_not_send_email(self):
|
def test_reject_with_prejudice_does_not_send_email(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue