mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-15 22:14:15 +02:00
Add an excessive number of boto3_mocking mocks
This commit is contained in:
parent
31c0396dd6
commit
91577e13de
1 changed files with 190 additions and 97 deletions
|
@ -1,6 +1,6 @@
|
|||
from django.test import TestCase
|
||||
from django.db.utils import IntegrityError
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from registrar.models import (
|
||||
Contact,
|
||||
|
@ -97,6 +97,9 @@ class TestDomainApplication(TestCase):
|
|||
def test_status_fsm_submit_fail(self):
|
||||
user, _ = User.objects.get_or_create()
|
||||
application = DomainApplication.objects.create(creator=user)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(ValueError):
|
||||
# can't submit an application with a null domain name
|
||||
application.submit()
|
||||
|
@ -105,7 +108,10 @@ class TestDomainApplication(TestCase):
|
|||
user, _ = User.objects.get_or_create()
|
||||
site = DraftDomain.objects.create(name="igorville.gov")
|
||||
application = DomainApplication.objects.create(creator=user, requested_domain=site)
|
||||
|
||||
# no submitter email so this emits a log warning
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with less_console_noise():
|
||||
application.submit()
|
||||
self.assertEqual(application.status, application.ApplicationStatus.SUBMITTED)
|
||||
|
@ -121,6 +127,9 @@ class TestDomainApplication(TestCase):
|
|||
submitter=contact,
|
||||
)
|
||||
application.save()
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
application.submit()
|
||||
|
||||
# check to see if an email was sent
|
||||
|
@ -141,6 +150,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.SUBMITTED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.submit()
|
||||
|
||||
|
@ -150,6 +161,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.IN_REVIEW)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.submit()
|
||||
|
||||
|
@ -159,6 +172,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.APPROVED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.submit()
|
||||
|
||||
|
@ -168,6 +183,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.REJECTED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.submit()
|
||||
|
||||
|
@ -177,6 +194,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.INELIGIBLE)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.submit()
|
||||
|
||||
|
@ -186,6 +205,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.STARTED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.in_review()
|
||||
|
||||
|
@ -195,6 +216,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.IN_REVIEW)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.in_review()
|
||||
|
||||
|
@ -204,6 +227,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.APPROVED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.in_review()
|
||||
|
||||
|
@ -213,6 +238,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.ACTION_NEEDED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.in_review()
|
||||
|
||||
|
@ -222,6 +249,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.REJECTED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.in_review()
|
||||
|
||||
|
@ -231,6 +260,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.WITHDRAWN)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.in_review()
|
||||
|
||||
|
@ -240,6 +271,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.INELIGIBLE)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.in_review()
|
||||
|
||||
|
@ -249,6 +282,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.STARTED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.action_needed()
|
||||
|
||||
|
@ -258,6 +293,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.SUBMITTED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.action_needed()
|
||||
|
||||
|
@ -267,6 +304,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.ACTION_NEEDED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.action_needed()
|
||||
|
||||
|
@ -276,6 +315,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.APPROVED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.action_needed()
|
||||
|
||||
|
@ -285,6 +326,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.WITHDRAWN)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.action_needed()
|
||||
|
||||
|
@ -294,6 +337,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.INELIGIBLE)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.action_needed()
|
||||
|
||||
|
@ -303,6 +348,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.STARTED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.approve()
|
||||
|
||||
|
@ -312,6 +359,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.APPROVED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.approve()
|
||||
|
||||
|
@ -321,6 +370,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.ACTION_NEEDED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.approve()
|
||||
|
||||
|
@ -330,6 +381,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.WITHDRAWN)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.approve()
|
||||
|
||||
|
@ -339,6 +392,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.STARTED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.withdraw()
|
||||
|
||||
|
@ -348,6 +403,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.APPROVED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.withdraw()
|
||||
|
||||
|
@ -357,6 +414,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.ACTION_NEEDED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.withdraw()
|
||||
|
||||
|
@ -366,6 +425,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.REJECTED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.withdraw()
|
||||
|
||||
|
@ -375,6 +436,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.WITHDRAWN)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.withdraw()
|
||||
|
||||
|
@ -384,6 +447,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.INELIGIBLE)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.withdraw()
|
||||
|
||||
|
@ -393,6 +458,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.STARTED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.reject()
|
||||
|
||||
|
@ -402,6 +469,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.SUBMITTED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.reject()
|
||||
|
||||
|
@ -411,6 +480,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.ACTION_NEEDED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.reject()
|
||||
|
||||
|
@ -420,6 +491,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.WITHDRAWN)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.reject()
|
||||
|
||||
|
@ -429,6 +502,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.REJECTED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.reject()
|
||||
|
||||
|
@ -438,6 +513,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.INELIGIBLE)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.reject()
|
||||
|
||||
|
@ -454,6 +531,8 @@ class TestDomainApplication(TestCase):
|
|||
def custom_is_active(self):
|
||||
return True # Override to return True
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
# Use patch to temporarily replace is_active with the custom implementation
|
||||
with patch.object(Domain, "is_active", custom_is_active):
|
||||
# Now, when you call is_active on Domain, it will return True
|
||||
|
@ -466,6 +545,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.STARTED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.reject_with_prejudice()
|
||||
|
||||
|
@ -475,6 +556,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.SUBMITTED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.reject_with_prejudice()
|
||||
|
||||
|
@ -484,6 +567,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.ACTION_NEEDED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.reject_with_prejudice()
|
||||
|
||||
|
@ -493,6 +578,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.WITHDRAWN)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.reject_with_prejudice()
|
||||
|
||||
|
@ -502,6 +589,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.REJECTED)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.reject_with_prejudice()
|
||||
|
||||
|
@ -511,6 +600,8 @@ class TestDomainApplication(TestCase):
|
|||
|
||||
application = completed_application(status=DomainApplication.ApplicationStatus.INELIGIBLE)
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
with self.assertRaises(TransitionNotAllowed):
|
||||
application.reject_with_prejudice()
|
||||
|
||||
|
@ -527,6 +618,8 @@ class TestDomainApplication(TestCase):
|
|||
def custom_is_active(self):
|
||||
return True # Override to return True
|
||||
|
||||
mock_client = MagicMock()
|
||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||
# Use patch to temporarily replace is_active with the custom implementation
|
||||
with patch.object(Domain, "is_active", custom_is_active):
|
||||
# Now, when you call is_active on Domain, it will return True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue