mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-25 20:18:38 +02:00
Fix some unit tests, linting
Have a few more to nail down, but this is most of them
This commit is contained in:
parent
4eae72d983
commit
b30802d3d7
5 changed files with 38 additions and 19 deletions
|
@ -530,6 +530,7 @@ def completed_application(
|
||||||
user=False,
|
user=False,
|
||||||
submitter=False,
|
submitter=False,
|
||||||
name="city.gov",
|
name="city.gov",
|
||||||
|
investigator=None,
|
||||||
):
|
):
|
||||||
"""A completed domain application."""
|
"""A completed domain application."""
|
||||||
if not user:
|
if not user:
|
||||||
|
@ -574,6 +575,7 @@ def completed_application(
|
||||||
submitter=submitter,
|
submitter=submitter,
|
||||||
creator=user,
|
creator=user,
|
||||||
status=status,
|
status=status,
|
||||||
|
investigator=investigator,
|
||||||
)
|
)
|
||||||
if has_about_your_organization:
|
if has_about_your_organization:
|
||||||
domain_application_kwargs["about_your_organization"] = "e-Government"
|
domain_application_kwargs["about_your_organization"] = "e-Government"
|
||||||
|
|
|
@ -27,29 +27,30 @@ from django_fsm import TransitionNotAllowed
|
||||||
@boto3_mocking.patching
|
@boto3_mocking.patching
|
||||||
class TestDomainApplication(TestCase):
|
class TestDomainApplication(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
user, _ = User.objects.get_or_create(username="testpancakesyrup", is_staff=True)
|
||||||
self.started_application = completed_application(
|
self.started_application = completed_application(
|
||||||
status=DomainApplication.ApplicationStatus.STARTED, name="started.gov"
|
status=DomainApplication.ApplicationStatus.STARTED, name="started.gov", investigator=user
|
||||||
)
|
)
|
||||||
self.submitted_application = completed_application(
|
self.submitted_application = completed_application(
|
||||||
status=DomainApplication.ApplicationStatus.SUBMITTED, name="submitted.gov"
|
status=DomainApplication.ApplicationStatus.SUBMITTED, name="submitted.gov", investigator=user
|
||||||
)
|
)
|
||||||
self.in_review_application = completed_application(
|
self.in_review_application = completed_application(
|
||||||
status=DomainApplication.ApplicationStatus.IN_REVIEW, name="in-review.gov"
|
status=DomainApplication.ApplicationStatus.IN_REVIEW, name="in-review.gov", investigator=user
|
||||||
)
|
)
|
||||||
self.action_needed_application = completed_application(
|
self.action_needed_application = completed_application(
|
||||||
status=DomainApplication.ApplicationStatus.ACTION_NEEDED, name="action-needed.gov"
|
status=DomainApplication.ApplicationStatus.ACTION_NEEDED, name="action-needed.gov", investigator=user
|
||||||
)
|
)
|
||||||
self.approved_application = completed_application(
|
self.approved_application = completed_application(
|
||||||
status=DomainApplication.ApplicationStatus.APPROVED, name="approved.gov"
|
status=DomainApplication.ApplicationStatus.APPROVED, name="approved.gov", investigator=user
|
||||||
)
|
)
|
||||||
self.withdrawn_application = completed_application(
|
self.withdrawn_application = completed_application(
|
||||||
status=DomainApplication.ApplicationStatus.WITHDRAWN, name="withdrawn.gov"
|
status=DomainApplication.ApplicationStatus.WITHDRAWN, name="withdrawn.gov", investigator=user
|
||||||
)
|
)
|
||||||
self.rejected_application = completed_application(
|
self.rejected_application = completed_application(
|
||||||
status=DomainApplication.ApplicationStatus.REJECTED, name="rejected.gov"
|
status=DomainApplication.ApplicationStatus.REJECTED, name="rejected.gov", investigator=user
|
||||||
)
|
)
|
||||||
self.ineligible_application = completed_application(
|
self.ineligible_application = completed_application(
|
||||||
status=DomainApplication.ApplicationStatus.INELIGIBLE, name="ineligible.gov"
|
status=DomainApplication.ApplicationStatus.INELIGIBLE, name="ineligible.gov", investigator=user
|
||||||
)
|
)
|
||||||
|
|
||||||
self.mock_client = MockSESClient()
|
self.mock_client = MockSESClient()
|
||||||
|
@ -161,7 +162,7 @@ class TestDomainApplication(TestCase):
|
||||||
application.submit()
|
application.submit()
|
||||||
self.assertEqual(application.status, application.ApplicationStatus.SUBMITTED)
|
self.assertEqual(application.status, application.ApplicationStatus.SUBMITTED)
|
||||||
|
|
||||||
def check_email_sent(self, application, msg, action, expected_count):
|
def check_email_sent(self, application: DomainApplication, msg, action, expected_count):
|
||||||
"""Check if an email was sent after performing an action."""
|
"""Check if an email was sent after performing an action."""
|
||||||
|
|
||||||
with self.subTest(msg=msg, action=action):
|
with self.subTest(msg=msg, action=action):
|
||||||
|
@ -169,7 +170,14 @@ class TestDomainApplication(TestCase):
|
||||||
with less_console_noise():
|
with less_console_noise():
|
||||||
# Perform the specified action
|
# Perform the specified action
|
||||||
action_method = getattr(application, action)
|
action_method = getattr(application, action)
|
||||||
action_method()
|
if action == "approve" and not application.investigator:
|
||||||
|
user, _ = User.objects.get_or_create(username="testwafflesyrup", is_staff=True)
|
||||||
|
application.investigator = user
|
||||||
|
application.save()
|
||||||
|
application.refresh_from_db()
|
||||||
|
action_method()
|
||||||
|
else:
|
||||||
|
action_method()
|
||||||
|
|
||||||
# Check if an email was sent
|
# Check if an email was sent
|
||||||
sent_emails = [
|
sent_emails = [
|
||||||
|
@ -616,7 +624,10 @@ class TestPermissions(TestCase):
|
||||||
def test_approval_creates_role(self):
|
def test_approval_creates_role(self):
|
||||||
draft_domain, _ = DraftDomain.objects.get_or_create(name="igorville.gov")
|
draft_domain, _ = DraftDomain.objects.get_or_create(name="igorville.gov")
|
||||||
user, _ = User.objects.get_or_create()
|
user, _ = User.objects.get_or_create()
|
||||||
application = DomainApplication.objects.create(creator=user, requested_domain=draft_domain)
|
investigator, _ = User.objects.get_or_create(username="frenchtoast", is_staff=True)
|
||||||
|
application = DomainApplication.objects.create(
|
||||||
|
creator=user, requested_domain=draft_domain, investigator=investigator
|
||||||
|
)
|
||||||
|
|
||||||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
|
with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
|
||||||
with less_console_noise():
|
with less_console_noise():
|
||||||
|
@ -650,7 +661,10 @@ class TestDomainInformation(TestCase):
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
draft_domain, _ = DraftDomain.objects.get_or_create(name="igorville.gov")
|
draft_domain, _ = DraftDomain.objects.get_or_create(name="igorville.gov")
|
||||||
user, _ = User.objects.get_or_create()
|
user, _ = User.objects.get_or_create()
|
||||||
application = DomainApplication.objects.create(creator=user, requested_domain=draft_domain, notes="test notes")
|
investigator, _ = User.objects.get_or_create(username="frenchtoast", is_staff=True)
|
||||||
|
application = DomainApplication.objects.create(
|
||||||
|
creator=user, requested_domain=draft_domain, notes="test notes", investigator=investigator
|
||||||
|
)
|
||||||
|
|
||||||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
|
with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
|
||||||
with less_console_noise():
|
with less_console_noise():
|
||||||
|
|
|
@ -270,7 +270,10 @@ class TestDomainCreation(MockEppLib):
|
||||||
"""
|
"""
|
||||||
draft_domain, _ = DraftDomain.objects.get_or_create(name="igorville.gov")
|
draft_domain, _ = DraftDomain.objects.get_or_create(name="igorville.gov")
|
||||||
user, _ = User.objects.get_or_create()
|
user, _ = User.objects.get_or_create()
|
||||||
application = DomainApplication.objects.create(creator=user, requested_domain=draft_domain)
|
investigator, _ = User.objects.get_or_create(username="frenchtoast", is_staff=True)
|
||||||
|
application = DomainApplication.objects.create(
|
||||||
|
creator=user, requested_domain=draft_domain, investigator=investigator
|
||||||
|
)
|
||||||
|
|
||||||
mock_client = MockSESClient()
|
mock_client = MockSESClient()
|
||||||
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
with boto3_mocking.clients.handler_for("sesv2", mock_client):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue