From f2e7278a86e4aa9e997effeeee83b3a5bd34b959 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 16 Feb 2024 17:42:09 -0500 Subject: [PATCH] updated tests --- src/registrar/tests/test_admin.py | 17 ---------- src/registrar/tests/test_models.py | 50 ++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py index 6142c2aee..5f8ea8fc1 100644 --- a/src/registrar/tests/test_admin.py +++ b/src/registrar/tests/test_admin.py @@ -649,23 +649,6 @@ class TestDomainApplicationAdmin(MockEppLib): self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL) self.assertEqual(len(self.mock_client.EMAILS_SENT), 2) - def test_save_model_clear_rejected_reason(self): - """When transitioning from rejected on a domain request, - the rejected_reason is cleared.""" - - # Create a sample application - application = completed_application(status=DomainApplication.ApplicationStatus.REJECTED) - application.rejected_reason = DomainApplication.RejectionReasons.DOMAIN_PURPOSE - application.save() - - # Approve - with boto3_mocking.clients.handler_for("sesv2", self.mock_client): - application.approve() - - application.refresh_from_db() - self.assertEqual(application.rejected_reason, None) - - def test_save_model_sends_withdrawn_email(self): """When transitioning to withdrawn on a domain request, an email is sent out every time.""" diff --git a/src/registrar/tests/test_models.py b/src/registrar/tests/test_models.py index cb7906d7a..f243956ff 100644 --- a/src/registrar/tests/test_models.py +++ b/src/registrar/tests/test_models.py @@ -574,6 +574,56 @@ class TestDomainApplication(TestCase): with self.assertRaises(TransitionNotAllowed): self.approved_application.reject_with_prejudice() + def test_approve_from_rejected_clears_rejection_reason(self): + """When transitioning from rejected to approved on a domain request, + the rejection_reason is cleared.""" + + with less_console_noise(): + # Create a sample application + application = completed_application(status=DomainApplication.ApplicationStatus.REJECTED) + application.rejection_reason = DomainApplication.RejectionReasons.DOMAIN_PURPOSE + + # Approve + with boto3_mocking.clients.handler_for("sesv2", self.mock_client): + application.approve() + + self.assertEqual(application.status, DomainApplication.ApplicationStatus.APPROVED) + self.assertEqual(application.rejection_reason, None) + + def test_in_review_from_rejected_clears_rejection_reason(self): + """When transitioning from rejected to in_review on a domain request, + the rejection_reason is cleared.""" + + with less_console_noise(): + # Create a sample application + application = completed_application(status=DomainApplication.ApplicationStatus.REJECTED) + application.domain_is_not_active = True + application.rejection_reason = DomainApplication.RejectionReasons.DOMAIN_PURPOSE + + # Approve + with boto3_mocking.clients.handler_for("sesv2", self.mock_client): + application.in_review() + + self.assertEqual(application.status, DomainApplication.ApplicationStatus.IN_REVIEW) + self.assertEqual(application.rejection_reason, None) + + def test_action_needed_from_rejected_clears_rejection_reason(self): + """When transitioning from rejected to action_needed on a domain request, + the rejection_reason is cleared.""" + + with less_console_noise(): + # Create a sample application + application = completed_application(status=DomainApplication.ApplicationStatus.REJECTED) + application.domain_is_not_active = True + application.rejection_reason = DomainApplication.RejectionReasons.DOMAIN_PURPOSE + + # Approve + with boto3_mocking.clients.handler_for("sesv2", self.mock_client): + application.action_needed() + + self.assertEqual(application.status, DomainApplication.ApplicationStatus.ACTION_NEEDED) + self.assertEqual(application.rejection_reason, None) + def test_has_rationale_returns_true(self): """has_rationale() returns true when an application has no_other_contacts_rationale""" with less_console_noise():