mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-18 10:29:23 +02:00
Fix tests not within helpers
This commit is contained in:
parent
866204cb8d
commit
9f6d1324d9
2 changed files with 27 additions and 5 deletions
|
@ -576,7 +576,8 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
):
|
||||
"""Helper method for the email test cases."""
|
||||
|
||||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
|
||||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client), ExitStack() as stack:
|
||||
stack.enter_context(patch.object(messages, "warning"))
|
||||
# Create a mock request
|
||||
request = self.factory.post("/admin/registrar/domainrequest/{}/change/".format(domain_request.pk))
|
||||
|
||||
|
@ -1155,6 +1156,7 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
|
||||
with ExitStack() as stack:
|
||||
stack.enter_context(patch.object(messages, "error"))
|
||||
stack.enter_context(patch.object(messages, "warning"))
|
||||
domain_request.status = DomainRequest.DomainRequestStatus.REJECTED
|
||||
|
||||
self.admin.save_model(request, domain_request, None, True)
|
||||
|
@ -1183,6 +1185,7 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
|
||||
with ExitStack() as stack:
|
||||
stack.enter_context(patch.object(messages, "error"))
|
||||
stack.enter_context(patch.object(messages, "warning"))
|
||||
domain_request.status = DomainRequest.DomainRequestStatus.REJECTED
|
||||
domain_request.rejection_reason = DomainRequest.RejectionReasons.CONTACTS_OR_ORGANIZATION_LEGITIMACY
|
||||
|
||||
|
@ -1234,11 +1237,13 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
request = self.factory.post("/admin/registrar/domainrequest/{}/change/".format(domain_request.pk))
|
||||
|
||||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
|
||||
# Modify the domain request's property
|
||||
domain_request.status = DomainRequest.DomainRequestStatus.APPROVED
|
||||
with ExitStack() as stack:
|
||||
stack.enter_context(patch.object(messages, "warning"))
|
||||
# Modify the domain request's property
|
||||
domain_request.status = DomainRequest.DomainRequestStatus.APPROVED
|
||||
|
||||
# Use the model admin's save_model method
|
||||
self.admin.save_model(request, domain_request, form=None, change=True)
|
||||
# Use the model admin's save_model method
|
||||
self.admin.save_model(request, domain_request, form=None, change=True)
|
||||
|
||||
# Test that approved domain exists and equals requested domain
|
||||
self.assertEqual(domain_request.requested_domain.name, domain_request.approved_domain.name)
|
||||
|
|
|
@ -345,6 +345,22 @@ class TestDomainDetail(TestDomainOverview):
|
|||
|
||||
|
||||
class TestDomainManagers(TestDomainOverview):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
allowed_emails = [
|
||||
AllowedEmail(email=""),
|
||||
AllowedEmail(email="testy@town.com"),
|
||||
AllowedEmail(email="mayor@igorville.gov"),
|
||||
AllowedEmail(email="testy2@town.com"),
|
||||
]
|
||||
AllowedEmail.objects.bulk_create(allowed_emails)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super().tearDownClass()
|
||||
AllowedEmail.objects.all().delete()
|
||||
|
||||
def tearDown(self):
|
||||
"""Ensure that the user has its original permissions"""
|
||||
super().tearDown()
|
||||
|
@ -567,6 +583,7 @@ class TestDomainManagers(TestDomainOverview):
|
|||
"""Inviting a user sends them an email, with email as the name."""
|
||||
# Create a fake user object
|
||||
email_address = "mayor@igorville.gov"
|
||||
allowed_email = AllowedEmail.objects.get_or_create(email=email_address)
|
||||
User.objects.get_or_create(email=email_address, username="fakeuser@fakeymail.com")
|
||||
|
||||
# Make sure the user is staff
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue