diff --git a/src/registrar/models/domain_request.py b/src/registrar/models/domain_request.py index 426d81ea3..617143ac7 100644 --- a/src/registrar/models/domain_request.py +++ b/src/registrar/models/domain_request.py @@ -689,7 +689,7 @@ class DomainRequest(TimeStampedModel): "reason": self.rejection_reason, "email": self.rejection_reason_email, "excluded_reasons": [DomainRequest.RejectionReasons.OTHER], - } + }, } status_info = status_information.get(status) @@ -952,7 +952,7 @@ class DomainRequest(TimeStampedModel): As side effects this will delete the domain and domain_information (will cascade) when they exist. - + Afterwards, we send out an email for action_needed in def save(). See the function send_custom_status_update_email. """ diff --git a/src/registrar/tests/test_admin_request.py b/src/registrar/tests/test_admin_request.py index 382a1e973..5104f23fb 100644 --- a/src/registrar/tests/test_admin_request.py +++ b/src/registrar/tests/test_admin_request.py @@ -595,12 +595,13 @@ class TestDomainRequestAdmin(MockEppLib): @less_console_noise_decorator def transition_state_and_send_email( - self, - domain_request, - status, - rejection_reason=None, - rejection_reason_email=None, - action_needed_reason=None, action_needed_reason_email=None + self, + domain_request, + status, + rejection_reason=None, + rejection_reason_email=None, + action_needed_reason=None, + action_needed_reason_email=None, ): """Helper method for the email test cases.""" @@ -617,7 +618,7 @@ class TestDomainRequestAdmin(MockEppLib): if rejection_reason: domain_request.rejection_reason = rejection_reason - + if 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.NAMING_REQUIREMENTS: "does not meet our naming requirements", # TODO - add back other? - #DomainRequest.RejectionReasons.OTHER: "", + # DomainRequest.RejectionReasons.OTHER: "", } for i, (reason, email_content) in enumerate(expected_emails.items()): with self.subTest(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.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 domain_purpose = DomainRequest.RejectionReasons.DOMAIN_PURPOSE @@ -1073,7 +1074,9 @@ class TestDomainRequestAdmin(MockEppLib): # Reject for reason REQUESTOR and test email including dynamic organization name 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( "Your domain request was rejected because we don’t believe you’re eligible to request a \n.gov " diff --git a/src/registrar/tests/test_models.py b/src/registrar/tests/test_models.py index dab8ff242..0b01ee0a6 100644 --- a/src/registrar/tests/test_models.py +++ b/src/registrar/tests/test_models.py @@ -46,6 +46,7 @@ from api.tests.common import less_console_noise_decorator logger = logging.getLogger(__name__) + @boto3_mocking.patching class TestDomainRequest(TestCase): @less_console_noise_decorator @@ -293,6 +294,8 @@ class TestDomainRequest(TestCase): # Perform the specified action action_method = getattr(domain_request, action) action_method() + domain_request.save() + domain_request.refresh_from_db() # Check if an email was sent sent_emails = [ diff --git a/src/registrar/utility/admin_helpers.py b/src/registrar/utility/admin_helpers.py index 19ea4c7b5..ad7ecae19 100644 --- a/src/registrar/utility/admin_helpers.py +++ b/src/registrar/utility/admin_helpers.py @@ -8,7 +8,7 @@ def get_action_needed_reason_default_email(domain_request, action_needed_reason) domain_request, file_path=f"emails/action_needed_reasons/{action_needed_reason}.txt", 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] ) + def _get_default_email(domain_request, file_path, reason, excluded_reasons=None): if not reason: return None