diff --git a/src/registrar/tests/common.py b/src/registrar/tests/common.py index 5dfd51d47..85341e02a 100644 --- a/src/registrar/tests/common.py +++ b/src/registrar/tests/common.py @@ -744,6 +744,7 @@ class MockDb(TestCase): User.objects.all().delete() UserDomainRole.objects.all().delete() DomainInvitation.objects.all().delete() + FederalAgency.objects.all().delete() def mock_user(): diff --git a/src/registrar/tests/test_transition_domain_migrations.py b/src/registrar/tests/test_transition_domain_migrations.py index 9311b59f7..eb1a334e6 100644 --- a/src/registrar/tests/test_transition_domain_migrations.py +++ b/src/registrar/tests/test_transition_domain_migrations.py @@ -11,6 +11,7 @@ from registrar.models import ( TransitionDomain, DomainInformation, UserDomainRole, + FederalAgency ) from django.core.management import call_command @@ -42,6 +43,7 @@ class TestProcessedMigrations(TestCase): DomainInformation.objects.all().delete() DomainInvitation.objects.all().delete() TransitionDomain.objects.all().delete() + FederalAgency.objects.all().delete() # Delete users User.objects.all().delete() @@ -329,6 +331,7 @@ class TestOrganizationMigration(TestCase): # Lets test the first one transition = transition_domains.first() + federal_agency, _ = FederalAgency.objects.get_or_create(agency="Department of Commerce") expected_transition_domain = TransitionDomain( username="alexandra.bobbitt5@test.com", domain_name="fakewebsite2.gov", @@ -337,7 +340,7 @@ class TestOrganizationMigration(TestCase): generic_org_type="Federal", organization_name="Fanoodle", federal_type="Executive", - federal_agency="Department of Commerce", + federal_agency=federal_agency, epp_creation_date=datetime.date(2004, 5, 7), epp_expiration_date=datetime.date(2023, 9, 30), first_name="Seline", @@ -392,6 +395,7 @@ class TestOrganizationMigration(TestCase): # == Third, test that we've loaded data as we expect == # _domain = Domain.objects.filter(name="fakewebsite2.gov").get() domain_information = DomainInformation.objects.filter(domain=_domain).get() + federal_agency, _ = FederalAgency.objects.get_or_create(agency="Department of Commerce") expected_creator = User.objects.filter(username="System").get() expected_ao = Contact.objects.filter( @@ -400,7 +404,7 @@ class TestOrganizationMigration(TestCase): expected_domain_information = DomainInformation( creator=expected_creator, generic_org_type="federal", - federal_agency="Department of Commerce", + federal_agency=federal_agency, federal_type="executive", organization_name="Fanoodle", address_line1="93001 Arizona Drive", @@ -447,6 +451,7 @@ class TestOrganizationMigration(TestCase): # == Fourth, test that no data is overwritten as we expect == # _domain = Domain.objects.filter(name="fakewebsite2.gov").get() domain_information = DomainInformation.objects.filter(domain=_domain).get() + federal_agency, _ = FederalAgency.objects.get_or_create(agency="Department of Commerce") expected_creator = User.objects.filter(username="System").get() expected_ao = Contact.objects.filter( @@ -455,7 +460,7 @@ class TestOrganizationMigration(TestCase): expected_domain_information = DomainInformation( creator=expected_creator, generic_org_type="federal", - federal_agency="Department of Commerce", + federal_agency=federal_agency, federal_type="executive", organization_name="Fanoodle", address_line1="93001 Galactic Way", diff --git a/src/registrar/tests/test_views_request.py b/src/registrar/tests/test_views_request.py index 22ad56646..1f99b1741 100644 --- a/src/registrar/tests/test_views_request.py +++ b/src/registrar/tests/test_views_request.py @@ -16,6 +16,7 @@ from registrar.models import ( Contact, User, Website, + FederalAgency ) from registrar.views.domain_request import DomainRequestWizard, Step @@ -178,7 +179,8 @@ class DomainRequestTests(TestWithUser, WebTest): org_contact_page = federal_result.follow() org_contact_form = org_contact_page.forms[0] # federal agency so we have to fill in federal_agency - org_contact_form["organization_contact-federal_agency"] = "General Services Administration" + federal_agency, _ = FederalAgency.objects.get_or_create(agency="General Services Administration") + org_contact_form["organization_contact-federal_agency"] = federal_agency org_contact_form["organization_contact-organization_name"] = "Testorg" org_contact_form["organization_contact-address_line1"] = "address 1" org_contact_form["organization_contact-address_line2"] = "address 2" @@ -2020,7 +2022,8 @@ class DomainRequestTests(TestWithUser, WebTest): org_contact_page = federal_result.follow() org_contact_form = org_contact_page.forms[0] # federal agency so we have to fill in federal_agency - org_contact_form["organization_contact-federal_agency"] = "General Services Administration" + federal_agency, _ = FederalAgency.objects.get_or_create(agency="General Services Administration") + org_contact_form["organization_contact-federal_agency"] = federal_agency org_contact_form["organization_contact-organization_name"] = "Testorg" org_contact_form["organization_contact-address_line1"] = "address 1" org_contact_form["organization_contact-address_line2"] = "address 2" @@ -2091,7 +2094,8 @@ class DomainRequestTests(TestWithUser, WebTest): org_contact_page = federal_result.follow() org_contact_form = org_contact_page.forms[0] # federal agency so we have to fill in federal_agency - org_contact_form["organization_contact-federal_agency"] = "General Services Administration" + federal_agency, _ = FederalAgency.objects.get_or_create(agency="General Services Administration") + org_contact_form["organization_contact-federal_agency"] = federal_agency org_contact_form["organization_contact-organization_name"] = "Testorg" org_contact_form["organization_contact-address_line1"] = "address 1" org_contact_form["organization_contact-address_line2"] = "address 2"