mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-16 14:34:10 +02:00
Add unit test
This commit is contained in:
parent
6415c645ee
commit
5039aff9aa
1 changed files with 28 additions and 4 deletions
|
@ -548,9 +548,9 @@ class TestPermissions(TestCase):
|
||||||
self.assertTrue(UserDomainRole.objects.get(user=user, domain=domain))
|
self.assertTrue(UserDomainRole.objects.get(user=user, domain=domain))
|
||||||
|
|
||||||
|
|
||||||
class TestDomainInfo(TestCase):
|
class TestDomainInformation(TestCase):
|
||||||
|
|
||||||
"""Test creation of Domain Information when approved."""
|
"""Test the DomainInformation model, when approved or otherwise"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
@ -559,12 +559,18 @@ class TestDomainInfo(TestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super().tearDown()
|
super().tearDown()
|
||||||
self.mock_client.EMAILS_SENT.clear()
|
self.mock_client.EMAILS_SENT.clear()
|
||||||
|
Domain.objects.all().delete()
|
||||||
|
DomainInformation.objects.all().delete()
|
||||||
|
DomainApplication.objects.all().delete()
|
||||||
|
User.objects.all().delete()
|
||||||
|
DraftDomain.objects.all().delete()
|
||||||
|
|
||||||
@boto3_mocking.patching
|
@boto3_mocking.patching
|
||||||
def test_approval_creates_info(self):
|
def test_approval_creates_info(self):
|
||||||
|
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)
|
application = DomainApplication.objects.create(creator=user, requested_domain=draft_domain, notes="test notes")
|
||||||
|
|
||||||
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():
|
||||||
|
@ -574,7 +580,25 @@ class TestDomainInfo(TestCase):
|
||||||
|
|
||||||
# should be an information present for this domain
|
# should be an information present for this domain
|
||||||
domain = Domain.objects.get(name="igorville.gov")
|
domain = Domain.objects.get(name="igorville.gov")
|
||||||
self.assertTrue(DomainInformation.objects.get(domain=domain))
|
domain_information = DomainInformation.objects.filter(domain=domain)
|
||||||
|
self.assertTrue(domain_information.exists())
|
||||||
|
|
||||||
|
# Test that both objects are what we expect
|
||||||
|
current_domain_information = domain_information.get().__dict__
|
||||||
|
expected_domain_information = DomainInformation(
|
||||||
|
creator=user,
|
||||||
|
domain=domain,
|
||||||
|
notes="test notes",
|
||||||
|
domain_application=application,
|
||||||
|
).__dict__
|
||||||
|
|
||||||
|
# Test the two records for consistency
|
||||||
|
self.assertEqual(self.clean_dict(current_domain_information), self.clean_dict(expected_domain_information))
|
||||||
|
|
||||||
|
def clean_dict(self, dict_obj):
|
||||||
|
"""Cleans dynamic fields in a dictionary"""
|
||||||
|
bad_fields = ["_state", "created_at", "id", "updated_at"]
|
||||||
|
return {k: v for k, v in dict_obj.items() if k not in bad_fields}
|
||||||
|
|
||||||
|
|
||||||
class TestInvitations(TestCase):
|
class TestInvitations(TestCase):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue