This commit is contained in:
zandercymatics 2024-10-01 10:28:40 -06:00
parent 0a7d4e460d
commit 06e4daef6a
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
4 changed files with 20 additions and 13 deletions

View file

@ -689,7 +689,7 @@ class DomainRequest(TimeStampedModel):
"reason": self.rejection_reason, "reason": self.rejection_reason,
"email": self.rejection_reason_email, "email": self.rejection_reason_email,
"excluded_reasons": [DomainRequest.RejectionReasons.OTHER], "excluded_reasons": [DomainRequest.RejectionReasons.OTHER],
} },
} }
status_info = status_information.get(status) status_info = status_information.get(status)
@ -952,7 +952,7 @@ class DomainRequest(TimeStampedModel):
As side effects this will delete the domain and domain_information As side effects this will delete the domain and domain_information
(will cascade) when they exist. (will cascade) when they exist.
Afterwards, we send out an email for action_needed in def save(). Afterwards, we send out an email for action_needed in def save().
See the function send_custom_status_update_email. See the function send_custom_status_update_email.
""" """

View file

@ -595,12 +595,13 @@ class TestDomainRequestAdmin(MockEppLib):
@less_console_noise_decorator @less_console_noise_decorator
def transition_state_and_send_email( def transition_state_and_send_email(
self, self,
domain_request, domain_request,
status, status,
rejection_reason=None, rejection_reason=None,
rejection_reason_email=None, rejection_reason_email=None,
action_needed_reason=None, action_needed_reason_email=None action_needed_reason=None,
action_needed_reason_email=None,
): ):
"""Helper method for the email test cases.""" """Helper method for the email test cases."""
@ -617,7 +618,7 @@ class TestDomainRequestAdmin(MockEppLib):
if rejection_reason: if rejection_reason:
domain_request.rejection_reason = rejection_reason domain_request.rejection_reason = rejection_reason
if rejection_reason_email: if rejection_reason_email:
domain_request.rejection_reason_email = rejection_reason_email domain_request.rejection_reason_email = rejection_reason_email
@ -798,13 +799,13 @@ class TestDomainRequestAdmin(MockEppLib):
DomainRequest.RejectionReasons.ORG_NOT_ELIGIBLE: ".Gov domains are only available to official U.S.-based", DomainRequest.RejectionReasons.ORG_NOT_ELIGIBLE: ".Gov domains are only available to official U.S.-based",
DomainRequest.RejectionReasons.NAMING_REQUIREMENTS: "does not meet our naming requirements", DomainRequest.RejectionReasons.NAMING_REQUIREMENTS: "does not meet our naming requirements",
# TODO - add back other? # TODO - add back other?
#DomainRequest.RejectionReasons.OTHER: "", # DomainRequest.RejectionReasons.OTHER: "",
} }
for i, (reason, email_content) in enumerate(expected_emails.items()): for i, (reason, email_content) in enumerate(expected_emails.items()):
with self.subTest(reason=reason): with self.subTest(reason=reason):
self.transition_state_and_send_email(domain_request, status=rejected, rejection_reason=reason) self.transition_state_and_send_email(domain_request, status=rejected, rejection_reason=reason)
self.assert_email_is_accurate(email_content, i, EMAIL, bcc_email_address=BCC_EMAIL) self.assert_email_is_accurate(email_content, i, EMAIL, bcc_email_address=BCC_EMAIL)
self.assertEqual(len(self.mock_client.EMAILS_SENT), i+1) self.assertEqual(len(self.mock_client.EMAILS_SENT), i + 1)
# Tests if an analyst can override existing email content # Tests if an analyst can override existing email content
domain_purpose = DomainRequest.RejectionReasons.DOMAIN_PURPOSE domain_purpose = DomainRequest.RejectionReasons.DOMAIN_PURPOSE
@ -1073,7 +1074,9 @@ class TestDomainRequestAdmin(MockEppLib):
# Reject for reason REQUESTOR and test email including dynamic organization name # Reject for reason REQUESTOR and test email including dynamic organization name
self.transition_state_and_send_email( self.transition_state_and_send_email(
domain_request, DomainRequest.DomainRequestStatus.REJECTED, DomainRequest.RejectionReasons.REQUESTOR_NOT_ELIGIBLE domain_request,
DomainRequest.DomainRequestStatus.REJECTED,
DomainRequest.RejectionReasons.REQUESTOR_NOT_ELIGIBLE,
) )
self.assert_email_is_accurate( self.assert_email_is_accurate(
"Your domain request was rejected because we dont believe youre eligible to request a \n.gov " "Your domain request was rejected because we dont believe youre eligible to request a \n.gov "

View file

@ -46,6 +46,7 @@ from api.tests.common import less_console_noise_decorator
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@boto3_mocking.patching @boto3_mocking.patching
class TestDomainRequest(TestCase): class TestDomainRequest(TestCase):
@less_console_noise_decorator @less_console_noise_decorator
@ -293,6 +294,8 @@ class TestDomainRequest(TestCase):
# Perform the specified action # Perform the specified action
action_method = getattr(domain_request, action) action_method = getattr(domain_request, action)
action_method() action_method()
domain_request.save()
domain_request.refresh_from_db()
# Check if an email was sent # Check if an email was sent
sent_emails = [ sent_emails = [

View file

@ -8,7 +8,7 @@ def get_action_needed_reason_default_email(domain_request, action_needed_reason)
domain_request, domain_request,
file_path=f"emails/action_needed_reasons/{action_needed_reason}.txt", file_path=f"emails/action_needed_reasons/{action_needed_reason}.txt",
reason=action_needed_reason, reason=action_needed_reason,
excluded_reasons=[DomainRequest.ActionNeededReasons.OTHER] excluded_reasons=[DomainRequest.ActionNeededReasons.OTHER],
) )
@ -21,6 +21,7 @@ def get_rejection_reason_default_email(domain_request, rejection_reason):
# excluded_reasons=[DomainRequest.RejectionReasons.OTHER] # excluded_reasons=[DomainRequest.RejectionReasons.OTHER]
) )
def _get_default_email(domain_request, file_path, reason, excluded_reasons=None): def _get_default_email(domain_request, file_path, reason, excluded_reasons=None):
if not reason: if not reason:
return None return None