mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-18 10:29:23 +02:00
Update from views to models to testing in backend
This commit is contained in:
parent
0effa81988
commit
27906bc310
4 changed files with 660 additions and 325 deletions
|
@ -938,3 +938,107 @@ class DomainRequest(TimeStampedModel):
|
||||||
for field in opts.many_to_many:
|
for field in opts.many_to_many:
|
||||||
data[field.name] = field.value_from_object(self)
|
data[field.name] = field.value_from_object(self)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def _is_federal_complete(self):
|
||||||
|
# Federal -> "Federal government branch" page can't be empty + Federal Agency selection can't be None
|
||||||
|
return not (self.federal_type is None or self.federal_agency is None)
|
||||||
|
|
||||||
|
def _is_interstate_complete(self):
|
||||||
|
# Interstate -> "About your organization" page can't be empty
|
||||||
|
return self.about_your_organization is not None
|
||||||
|
|
||||||
|
def _is_state_or_territory_complete(self):
|
||||||
|
# State -> ""Election office" page can't be empty
|
||||||
|
return self.is_election_board is not None
|
||||||
|
|
||||||
|
def _is_tribal_complete(self):
|
||||||
|
# Tribal -> "Tribal name" and "Election office" page can't be empty
|
||||||
|
return self.tribe_name is not None and self.is_election_board is not None
|
||||||
|
|
||||||
|
def _is_county_complete(self):
|
||||||
|
# County -> "Election office" page can't be empty
|
||||||
|
return self.is_election_board is not None
|
||||||
|
|
||||||
|
def _is_city_complete(self):
|
||||||
|
# City -> "Election office" page can't be empty
|
||||||
|
return self.is_election_board is not None
|
||||||
|
|
||||||
|
def _is_special_district_complete(self):
|
||||||
|
# Special District -> "Election office" and "About your organization" page can't be empty
|
||||||
|
return (
|
||||||
|
self.is_election_board is not None
|
||||||
|
and self.about_your_organization is not None
|
||||||
|
)
|
||||||
|
|
||||||
|
def _is_organization_name_and_address_complete(self):
|
||||||
|
return not (
|
||||||
|
self.organization_name is None
|
||||||
|
or self.address_line1 is None
|
||||||
|
or self.city is None
|
||||||
|
or self.state_territory is None
|
||||||
|
or self.zipcode is None
|
||||||
|
)
|
||||||
|
|
||||||
|
def _is_authorizing_official_complete(self):
|
||||||
|
return self.authorizing_official is not None
|
||||||
|
|
||||||
|
def _is_requested_domain_complete(self):
|
||||||
|
return self.requested_domain is not None
|
||||||
|
|
||||||
|
def _is_purpose_complete(self):
|
||||||
|
return self.purpose is not None
|
||||||
|
|
||||||
|
def _is_submitter_complete(self):
|
||||||
|
return self.submitter is not None
|
||||||
|
|
||||||
|
def _is_other_contacts_complete(self):
|
||||||
|
return self.other_contacts is not None
|
||||||
|
|
||||||
|
def _is_additional_details_complete(self):
|
||||||
|
return not (
|
||||||
|
self.has_cisa_representative is None
|
||||||
|
or self.has_anything_else_text is None
|
||||||
|
# RARE EDGE CASE: You click yes on having a cisa rep, but you dont type in email (should block in form)
|
||||||
|
or (
|
||||||
|
self.has_cisa_representative is True
|
||||||
|
and self.cisa_representative_email is None
|
||||||
|
)
|
||||||
|
or self.is_policy_acknowledged is None
|
||||||
|
)
|
||||||
|
|
||||||
|
def _is_general_form_complete(self):
|
||||||
|
return (
|
||||||
|
self._is_organization_name_and_address_complete()
|
||||||
|
and self._is_authorizing_official_complete()
|
||||||
|
and self._is_requested_domain_complete()
|
||||||
|
and self._is_purpose_complete()
|
||||||
|
and self._is_submitter_complete()
|
||||||
|
and self._is_other_contacts_complete()
|
||||||
|
and self._is_additional_details_complete()
|
||||||
|
)
|
||||||
|
|
||||||
|
def _form_complete(self):
|
||||||
|
if self.generic_org_type == DomainRequest.OrganizationChoices.FEDERAL:
|
||||||
|
is_complete = self._is_federal_complete()
|
||||||
|
elif self.generic_org_type == DomainRequest.OrganizationChoices.INTERSTATE:
|
||||||
|
is_complete = self._is_interstate_complete()
|
||||||
|
elif self.generic_org_type == DomainRequest.OrganizationChoices.STATE_OR_TERRITORY:
|
||||||
|
is_complete = self._is_state_or_territory_complete()
|
||||||
|
elif self.generic_org_type == DomainRequest.OrganizationChoices.TRIBAL:
|
||||||
|
is_complete = self._is_tribal_complete()
|
||||||
|
elif self.generic_org_type == DomainRequest.OrganizationChoices.COUNTY:
|
||||||
|
is_complete = self._is_county_complete()
|
||||||
|
elif self.generic_org_type == DomainRequest.OrganizationChoices.CITY:
|
||||||
|
is_complete = self._is_city_complete()
|
||||||
|
elif self.generic_org_type == DomainRequest.OrganizationChoices.SPECIAL_DISTRICT:
|
||||||
|
is_complete = self._is_special_district_complete()
|
||||||
|
else:
|
||||||
|
# NOTE: This shouldn't happen, this is only if somehow they didn't choose an org type
|
||||||
|
is_complete = False
|
||||||
|
|
||||||
|
if not is_complete or not self._is_general_form_complete():
|
||||||
|
print("!!!! We are in the False if statement - form is not complete")
|
||||||
|
return False
|
||||||
|
|
||||||
|
print("!!!! We are in the True if statement - form is complete")
|
||||||
|
return True
|
|
@ -1,6 +1,7 @@
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.db.utils import IntegrityError
|
from django.db.utils import IntegrityError
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
from django.contrib.auth import get_user_model
|
||||||
|
|
||||||
from registrar.models import (
|
from registrar.models import (
|
||||||
Contact,
|
Contact,
|
||||||
|
@ -1602,3 +1603,197 @@ class TestDomainInformationCustomSave(TestCase):
|
||||||
)
|
)
|
||||||
self.assertEqual(domain_information_election.is_election_board, True)
|
self.assertEqual(domain_information_election.is_election_board, True)
|
||||||
self.assertEqual(domain_information_election.generic_org_type, DomainRequest.OrganizationChoices.CITY)
|
self.assertEqual(domain_information_election.generic_org_type, DomainRequest.OrganizationChoices.CITY)
|
||||||
|
|
||||||
|
class TestDomainRequestIncomplete(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
|
username = "test_user"
|
||||||
|
first_name = "First"
|
||||||
|
last_name = "Last"
|
||||||
|
email = "info@example.com"
|
||||||
|
self.user = get_user_model().objects.create(
|
||||||
|
username=username, first_name=first_name, last_name=last_name, email=email
|
||||||
|
)
|
||||||
|
ao, _ = Contact.objects.get_or_create(
|
||||||
|
first_name="Meowy",
|
||||||
|
last_name="Meoward",
|
||||||
|
title="Chief Cat",
|
||||||
|
email="meoward@chiefcat.com",
|
||||||
|
phone="(206) 206 2060",
|
||||||
|
)
|
||||||
|
draft_domain, _ = DraftDomain.objects.get_or_create(name="MeowardMeowardMeoward.gov")
|
||||||
|
you, _ = Contact.objects.get_or_create(
|
||||||
|
first_name="Testy you",
|
||||||
|
last_name="Tester you",
|
||||||
|
title="Admin Tester",
|
||||||
|
email="testy-admin@town.com",
|
||||||
|
phone="(555) 555 5556",
|
||||||
|
)
|
||||||
|
other, _ = Contact.objects.get_or_create(
|
||||||
|
first_name="Testy2",
|
||||||
|
last_name="Tester2",
|
||||||
|
title="Another Tester",
|
||||||
|
email="testy2@town.com",
|
||||||
|
phone="(555) 555 5557",
|
||||||
|
)
|
||||||
|
# domain, _ = Domain.objects.get_or_create(name="MeowardMeowardMeoward.gov")
|
||||||
|
alt, _ = Website.objects.get_or_create(website="MeowardMeowardMeoward1.gov")
|
||||||
|
current, _ = Website.objects.get_or_create(website="MeowardMeowardMeoward.com")
|
||||||
|
self.domain_request = DomainRequest.objects.create(
|
||||||
|
generic_org_type=DomainRequest.OrganizationChoices.FEDERAL,
|
||||||
|
federal_type="executive",
|
||||||
|
federal_agency=FederalAgency.objects.get(agency="AMTRAK"),
|
||||||
|
about_your_organization="Some description",
|
||||||
|
is_election_board=True,
|
||||||
|
tribe_name="Some tribe name",
|
||||||
|
organization_name="Some organization",
|
||||||
|
address_line1="address 1",
|
||||||
|
state_territory="CA",
|
||||||
|
zipcode="94044",
|
||||||
|
authorizing_official=ao,
|
||||||
|
requested_domain=draft_domain,
|
||||||
|
purpose="Some purpose",
|
||||||
|
submitter=you,
|
||||||
|
has_cisa_representative=False,
|
||||||
|
has_anything_else_text="Some text",
|
||||||
|
is_policy_acknowledged=True,
|
||||||
|
creator=self.user,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.domain_request.other_contacts.add(other)
|
||||||
|
self.domain_request.current_websites.add(current)
|
||||||
|
self.domain_request.alternative_domains.add(alt)
|
||||||
|
|
||||||
|
def test_is_federal_complete(self):
|
||||||
|
self.domain_request.generic_org_type = DomainRequest.OrganizationChoices.FEDERAL
|
||||||
|
self.assertTrue(self.domain_request._is_federal_complete())
|
||||||
|
self.domain_request.federal_type = None
|
||||||
|
self.assertFalse(self.domain_request._is_federal_complete())
|
||||||
|
|
||||||
|
def test_is_interstate_complete(self):
|
||||||
|
self.domain_request.generic_org_type = DomainRequest.OrganizationChoices.INTERSTATE
|
||||||
|
self.assertTrue(self.domain_request._is_interstate_complete())
|
||||||
|
self.domain_request.about_your_organization = None
|
||||||
|
self.assertFalse(self.domain_request._is_interstate_complete())
|
||||||
|
|
||||||
|
def test_is_state_or_territory_complete(self):
|
||||||
|
self.domain_request.generic_org_type = DomainRequest.OrganizationChoices.STATE_OR_TERRITORY
|
||||||
|
self.assertTrue(self.domain_request._is_state_or_territory_complete())
|
||||||
|
self.domain_request.is_election_board = None
|
||||||
|
self.assertFalse(self.domain_request._is_state_or_territory_complete())
|
||||||
|
|
||||||
|
def test_is_tribal_complete(self):
|
||||||
|
self.domain_request.generic_org_type = DomainRequest.OrganizationChoices.TRIBAL
|
||||||
|
self.assertTrue(self.domain_request._is_tribal_complete())
|
||||||
|
self.domain_request.tribe_name = None
|
||||||
|
self.assertFalse(self.domain_request._is_tribal_complete())
|
||||||
|
|
||||||
|
def test_is_county_complete(self):
|
||||||
|
self.domain_request.generic_org_type = DomainRequest.OrganizationChoices.COUNTY
|
||||||
|
self.assertTrue(self.domain_request._is_county_complete())
|
||||||
|
self.domain_request.is_election_board = None
|
||||||
|
self.assertFalse(self.domain_request._is_county_complete())
|
||||||
|
|
||||||
|
def test_is_city_complete(self):
|
||||||
|
self.domain_request.generic_org_type = DomainRequest.OrganizationChoices.CITY
|
||||||
|
self.assertTrue(self.domain_request._is_city_complete())
|
||||||
|
self.domain_request.is_election_board = None
|
||||||
|
self.assertFalse(self.domain_request._is_city_complete())
|
||||||
|
|
||||||
|
def test_is_special_district_complete(self):
|
||||||
|
self.domain_request.generic_org_type = DomainRequest.OrganizationChoices.SPECIAL_DISTRICT
|
||||||
|
self.assertTrue(self.domain_request._is_special_district_complete())
|
||||||
|
self.domain_request.about_your_organization = None
|
||||||
|
self.assertFalse(self.domain_request._is_special_district_complete())
|
||||||
|
|
||||||
|
def test_is_organization_name_and_address_complete(self):
|
||||||
|
self.assertTrue(self.domain_request._is_organization_name_and_address_complete())
|
||||||
|
self.domain_request.organization_name = None
|
||||||
|
self.assertFalse(self.domain_request._is_organization_name_and_address_complete())
|
||||||
|
|
||||||
|
def test_is_authorizing_official_complete(self):
|
||||||
|
self.assertTrue(self.domain_request._is_authorizing_official_complete())
|
||||||
|
self.domain_request.authorizing_official = None
|
||||||
|
self.assertFalse(self.domain_request._is_authorizing_official_complete())
|
||||||
|
|
||||||
|
def test_is_requested_domain_complete(self):
|
||||||
|
self.assertTrue(self.domain_request._is_requested_domain_complete())
|
||||||
|
self.domain_request.requested_domain = None
|
||||||
|
self.assertFalse(self.domain_request._is_requested_domain_complete())
|
||||||
|
|
||||||
|
def test_is_purpose_complete(self):
|
||||||
|
self.assertTrue(self.domain_request._is_purpose_complete())
|
||||||
|
self.domain_request.purpose = None
|
||||||
|
self.assertFalse(self.domain_request._is_purpose_complete())
|
||||||
|
|
||||||
|
def test_is_submitter_complete(self):
|
||||||
|
self.assertTrue(self.domain_request._is_submitter_complete())
|
||||||
|
self.domain_request.submitter = None
|
||||||
|
self.assertFalse(self.domain_request._is_submitter_complete())
|
||||||
|
|
||||||
|
def test_is_other_contacts_complete(self):
|
||||||
|
self.assertTrue(self.domain_request._is_other_contacts_complete())
|
||||||
|
none_other_contacts, _ = Contact.objects.get_or_create(
|
||||||
|
first_name=None,
|
||||||
|
last_name=None,
|
||||||
|
title=None,
|
||||||
|
email=None,
|
||||||
|
phone=None,
|
||||||
|
)
|
||||||
|
self.domain_request.other_contacts.add(none_other_contacts)
|
||||||
|
self.assertFalse(self.domain_request._is_other_contacts_complete())
|
||||||
|
|
||||||
|
def test_is_additional_details_complete(self):
|
||||||
|
self.assertTrue(self.domain_request._is_additional_details_complete())
|
||||||
|
self.domain_request.has_cisa_representative = None
|
||||||
|
self.assertFalse(self.domain_request._is_additional_details_complete())
|
||||||
|
self.domain_request.has_cisa_representative = True
|
||||||
|
self.domain_request.cisa_representative_email = None
|
||||||
|
self.assertFalse(self.domain_request._is_additional_details_complete())
|
||||||
|
|
||||||
|
def test_is_general_form_complete(self):
|
||||||
|
self.assertTrue(self.domain_request._is_general_form_complete())
|
||||||
|
self.domain_request.organization_name = None
|
||||||
|
self.assertFalse(self.domain_request._is_general_form_complete())
|
||||||
|
|
||||||
|
def test_form_complete_for_federal(self):
|
||||||
|
self.domain_request.generic_org_type = DomainRequest.OrganizationChoices.FEDERAL
|
||||||
|
self.assertTrue(self.domain_request._form_complete())
|
||||||
|
self.domain_request.federal_type = None
|
||||||
|
self.assertFalse(self.domain_request._form_complete())
|
||||||
|
|
||||||
|
def test_form_complete_for_interstate(self):
|
||||||
|
self.domain_request.generic_org_type = DomainRequest.OrganizationChoices.INTERSTATE
|
||||||
|
self.assertTrue(self.domain_request._form_complete())
|
||||||
|
self.domain_request.about_your_organization = None
|
||||||
|
self.assertFalse(self.domain_request._form_complete())
|
||||||
|
|
||||||
|
def test_form_complete_for_state_or_territory(self):
|
||||||
|
self.domain_request.generic_org_type = DomainRequest.OrganizationChoices.STATE_OR_TERRITORY
|
||||||
|
self.assertTrue(self.domain_request._form_complete())
|
||||||
|
self.domain_request.is_election_board = None
|
||||||
|
self.assertFalse(self.domain_request._form_complete())
|
||||||
|
|
||||||
|
def test_form_complete_for_tribal(self):
|
||||||
|
self.domain_request.generic_org_type = DomainRequest.OrganizationChoices.TRIBAL
|
||||||
|
self.assertTrue(self.domain_request._form_complete())
|
||||||
|
self.domain_request.tribe_name = None
|
||||||
|
self.assertFalse(self.domain_request._form_complete())
|
||||||
|
|
||||||
|
def test_form_complete_for_county(self):
|
||||||
|
self.domain_request.generic_org_type = DomainRequest.OrganizationChoices.COUNTY
|
||||||
|
self.assertTrue(self.domain_request._form_complete())
|
||||||
|
self.domain_request.is_election_board = None
|
||||||
|
self.assertFalse(self.domain_request._form_complete())
|
||||||
|
|
||||||
|
def test_form_complete_for_city(self):
|
||||||
|
self.domain_request.generic_org_type = DomainRequest.OrganizationChoices.CITY
|
||||||
|
self.assertTrue(self.domain_request._form_complete())
|
||||||
|
self.domain_request.is_election_board = None
|
||||||
|
self.assertFalse(self.domain_request._form_complete())
|
||||||
|
|
||||||
|
def test_form_complete_for_special_district(self):
|
||||||
|
self.domain_request.generic_org_type = DomainRequest.OrganizationChoices.SPECIAL_DISTRICT
|
||||||
|
self.assertTrue(self.domain_request._form_complete())
|
||||||
|
self.domain_request.about_your_organization = None
|
||||||
|
self.assertFalse(self.domain_request._form_complete())
|
|
@ -511,271 +511,306 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
type_result = type_form.submit()
|
type_result = type_form.submit()
|
||||||
# should see results in db
|
# should see results in db
|
||||||
domain_request = DomainRequest.objects.get() # there's only one
|
domain_request = DomainRequest.objects.get() # there's only one
|
||||||
|
session = self.client.session
|
||||||
|
print("$$$$$$$$$$$$$$$$$$$ 514!!!!!!", session.values())
|
||||||
|
|
||||||
self.assertEqual(domain_request.generic_org_type, "tribal")
|
self.assertEqual(domain_request.generic_org_type, "tribal")
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(type_result.status_code, 302)
|
self.assertEqual(type_result.status_code, 302)
|
||||||
self.assertEqual(type_result["Location"], "/request/tribal_government/")
|
self.assertEqual(type_result["Location"], "/request/tribal_government/")
|
||||||
num_pages_tested += 1
|
# num_pages_tested += 1
|
||||||
|
|
||||||
# -- TRIBAL PAGE --
|
# -- TRIBAL PAGE --
|
||||||
# We want to skip the tribal page right?? but how do we not fill it out.............
|
|
||||||
type_form = type_page.forms[0]
|
type_form = type_page.forms[0]
|
||||||
type_form["generic_org_type-generic_org_type"] = DomainRequest.OrganizationChoices.TRIBAL
|
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
type_result = type_form.submit()
|
|
||||||
# the tribal government page comes immediately afterwards
|
# session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]"
|
||||||
self.assertIn("/tribal_government", type_result.headers["Location"])
|
url = reverse("domain-request:review")
|
||||||
# follow first redirect
|
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
tribal_government_page = type_result.follow()
|
session = self.client.session
|
||||||
|
# print("$$$$$$$$$$$$$$$$$$$ BEFORE", session.request)
|
||||||
|
print("$$$$$$$$$$$$$$$$$$$ BEFORE", session.values())
|
||||||
|
|
||||||
# and the step is on the sidebar list.
|
review_page = self.client.get(url, follow=True)
|
||||||
self.assertContains(tribal_government_page, self.TITLES[Step.TRIBAL_GOVERNMENT])
|
session = self.client.session
|
||||||
|
# print("$$$$$$$$$$$$$$$$$$$ AFTER", session.request)
|
||||||
|
print("$$$$$$$$$$$$$$$$$$$ AFTER", session.values())
|
||||||
# ---- ORG CONTACT PAGE ----
|
|
||||||
# Follow the redirect to the next form page
|
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
org_contact_page = type_result.follow()
|
# Org type is filled in
|
||||||
org_contact_form = org_contact_page.forms[0]
|
self.assertContains(review_page, "Tribal")
|
||||||
# federal agency so we have to fill in federal_agency
|
self.assertContains(review_page, "Incomplete", count=9)
|
||||||
# federal_agency, _ = FederalAgency.objects.get_or_create(agency="General Services Administration")
|
|
||||||
# org_contact_form["organization_contact-federal_agency"] = federal_agency.id
|
|
||||||
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"
|
|
||||||
org_contact_form["organization_contact-city"] = "NYC"
|
|
||||||
org_contact_form["organization_contact-state_territory"] = "NY"
|
|
||||||
org_contact_form["organization_contact-zipcode"] = "10002"
|
|
||||||
org_contact_form["organization_contact-urbanization"] = "URB Royal Oaks"
|
|
||||||
|
|
||||||
# test next button
|
# In theory we just need to check that tribal is incomplete
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
# I don't need to re-look at any of these underneath
|
||||||
org_contact_result = org_contact_form.submit()
|
# self.assertContains(review_page, "Executive")
|
||||||
# validate that data from this step are being saved
|
# self.assertContains(review_page, "You can’t submit this request")
|
||||||
domain_request = DomainRequest.objects.get() # there's only one
|
|
||||||
self.assertEqual(domain_request.organization_name, "Testorg")
|
|
||||||
self.assertEqual(domain_request.address_line1, "address 1")
|
|
||||||
self.assertEqual(domain_request.address_line2, "address 2")
|
|
||||||
self.assertEqual(domain_request.city, "NYC")
|
|
||||||
self.assertEqual(domain_request.state_territory, "NY")
|
|
||||||
self.assertEqual(domain_request.zipcode, "10002")
|
|
||||||
self.assertEqual(domain_request.urbanization, "URB Royal Oaks")
|
|
||||||
# the post request should return a redirect to the next form in
|
|
||||||
# the domain request page
|
|
||||||
self.assertEqual(org_contact_result.status_code, 302)
|
|
||||||
self.assertEqual(org_contact_result["Location"], "/request/authorizing_official/")
|
|
||||||
num_pages_tested += 1
|
|
||||||
|
|
||||||
# ---- AUTHORIZING OFFICIAL PAGE ----
|
# # final submission results in a redirect to the "finished" URL
|
||||||
# Follow the redirect to the next form page
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
# with less_console_noise():
|
||||||
ao_page = org_contact_result.follow()
|
# review_result = review_form.submit()
|
||||||
ao_form = ao_page.forms[0]
|
# print("!!!!!!!!!!!!!!!!!!! review_result", review_result)
|
||||||
ao_form["authorizing_official-first_name"] = "Testy ATO"
|
|
||||||
ao_form["authorizing_official-last_name"] = "Tester ATO"
|
|
||||||
ao_form["authorizing_official-title"] = "Chief Tester"
|
|
||||||
ao_form["authorizing_official-email"] = "testy@town.com"
|
|
||||||
|
|
||||||
# test next button
|
# print("!!!!!!!!!!!!!!!!!!! review_result.status_code", review_result.status_code)
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
# print("!!!!!!!!!!!!!!!!!!! review_results location", review_result["Location"])
|
||||||
ao_result = ao_form.submit()
|
|
||||||
# validate that data from this step are being saved
|
|
||||||
domain_request = DomainRequest.objects.get() # there's only one
|
|
||||||
self.assertEqual(domain_request.authorizing_official.first_name, "Testy ATO")
|
|
||||||
self.assertEqual(domain_request.authorizing_official.last_name, "Tester ATO")
|
|
||||||
self.assertEqual(domain_request.authorizing_official.title, "Chief Tester")
|
|
||||||
self.assertEqual(domain_request.authorizing_official.email, "testy@town.com")
|
|
||||||
# the post request should return a redirect to the next form in
|
|
||||||
# the domain request page
|
|
||||||
self.assertEqual(ao_result.status_code, 302)
|
|
||||||
self.assertEqual(ao_result["Location"], "/request/current_sites/")
|
|
||||||
num_pages_tested += 1
|
|
||||||
|
|
||||||
# ---- CURRENT SITES PAGE ----
|
# self.assertEqual(review_result.status_code, 302)
|
||||||
# Follow the redirect to the next form page
|
# self.assertEqual(review_result["Location"], "/request/finished/")
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
|
||||||
current_sites_page = ao_result.follow()
|
|
||||||
current_sites_form = current_sites_page.forms[0]
|
|
||||||
current_sites_form["current_sites-0-website"] = "www.city.com"
|
|
||||||
|
|
||||||
# test next button
|
# type_result = type_form.submit()
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
# # the tribal government page comes immediately afterwards
|
||||||
current_sites_result = current_sites_form.submit()
|
# self.assertIn("/tribal_government", type_result.headers["Location"])
|
||||||
# validate that data from this step are being saved
|
# # follow first redirect
|
||||||
domain_request = DomainRequest.objects.get() # there's only one
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
self.assertEqual(
|
# tribal_government_page = type_result.follow()
|
||||||
domain_request.current_websites.filter(website="http://www.city.com").count(),
|
|
||||||
1,
|
|
||||||
)
|
|
||||||
# the post request should return a redirect to the next form in
|
|
||||||
# the domain request page
|
|
||||||
self.assertEqual(current_sites_result.status_code, 302)
|
|
||||||
self.assertEqual(current_sites_result["Location"], "/request/dotgov_domain/")
|
|
||||||
num_pages_tested += 1
|
|
||||||
|
|
||||||
# ---- DOTGOV DOMAIN PAGE ----
|
# # and the step is on the sidebar list.
|
||||||
# Follow the redirect to the next form page
|
# self.assertContains(tribal_government_page, self.TITLES[Step.TRIBAL_GOVERNMENT])
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
|
||||||
dotgov_page = current_sites_result.follow()
|
|
||||||
dotgov_form = dotgov_page.forms[0]
|
|
||||||
dotgov_form["dotgov_domain-requested_domain"] = "city"
|
|
||||||
dotgov_form["dotgov_domain-0-alternative_domain"] = "city1"
|
|
||||||
|
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
|
||||||
dotgov_result = dotgov_form.submit()
|
|
||||||
# validate that data from this step are being saved
|
|
||||||
domain_request = DomainRequest.objects.get() # there's only one
|
|
||||||
self.assertEqual(domain_request.requested_domain.name, "city.gov")
|
|
||||||
self.assertEqual(domain_request.alternative_domains.filter(website="city1.gov").count(), 1)
|
|
||||||
# the post request should return a redirect to the next form in
|
|
||||||
# the domain request page
|
|
||||||
self.assertEqual(dotgov_result.status_code, 302)
|
|
||||||
self.assertEqual(dotgov_result["Location"], "/request/purpose/")
|
|
||||||
num_pages_tested += 1
|
|
||||||
|
|
||||||
# ---- PURPOSE PAGE ----
|
# # ---- ORG CONTACT PAGE ----
|
||||||
# Follow the redirect to the next form page
|
# # Follow the redirect to the next form page
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
purpose_page = dotgov_result.follow()
|
# org_contact_page = type_result.follow()
|
||||||
purpose_form = purpose_page.forms[0]
|
# org_contact_form = org_contact_page.forms[0]
|
||||||
purpose_form["purpose-purpose"] = "For all kinds of things."
|
# # federal agency so we have to fill in federal_agency
|
||||||
|
# # federal_agency, _ = FederalAgency.objects.get_or_create(agency="General Services Administration")
|
||||||
|
# # org_contact_form["organization_contact-federal_agency"] = federal_agency.id
|
||||||
|
# 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"
|
||||||
|
# org_contact_form["organization_contact-city"] = "NYC"
|
||||||
|
# org_contact_form["organization_contact-state_territory"] = "NY"
|
||||||
|
# org_contact_form["organization_contact-zipcode"] = "10002"
|
||||||
|
# org_contact_form["organization_contact-urbanization"] = "URB Royal Oaks"
|
||||||
|
|
||||||
# test next button
|
# # test next button
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
purpose_result = purpose_form.submit()
|
# org_contact_result = org_contact_form.submit()
|
||||||
# validate that data from this step are being saved
|
# # validate that data from this step are being saved
|
||||||
domain_request = DomainRequest.objects.get() # there's only one
|
# domain_request = DomainRequest.objects.get() # there's only one
|
||||||
self.assertEqual(domain_request.purpose, "For all kinds of things.")
|
# self.assertEqual(domain_request.organization_name, "Testorg")
|
||||||
# the post request should return a redirect to the next form in
|
# self.assertEqual(domain_request.address_line1, "address 1")
|
||||||
# the domain request page
|
# self.assertEqual(domain_request.address_line2, "address 2")
|
||||||
self.assertEqual(purpose_result.status_code, 302)
|
# self.assertEqual(domain_request.city, "NYC")
|
||||||
self.assertEqual(purpose_result["Location"], "/request/your_contact/")
|
# self.assertEqual(domain_request.state_territory, "NY")
|
||||||
num_pages_tested += 1
|
# self.assertEqual(domain_request.zipcode, "10002")
|
||||||
|
# self.assertEqual(domain_request.urbanization, "URB Royal Oaks")
|
||||||
|
# # the post request should return a redirect to the next form in
|
||||||
|
# # the domain request page
|
||||||
|
# self.assertEqual(org_contact_result.status_code, 302)
|
||||||
|
# self.assertEqual(org_contact_result["Location"], "/request/authorizing_official/")
|
||||||
|
# num_pages_tested += 1
|
||||||
|
|
||||||
# ---- YOUR CONTACT INFO PAGE ----
|
# # ---- AUTHORIZING OFFICIAL PAGE ----
|
||||||
# Follow the redirect to the next form page
|
# # Follow the redirect to the next form page
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
your_contact_page = purpose_result.follow()
|
# ao_page = org_contact_result.follow()
|
||||||
your_contact_form = your_contact_page.forms[0]
|
# ao_form = ao_page.forms[0]
|
||||||
|
# ao_form["authorizing_official-first_name"] = "Testy ATO"
|
||||||
|
# ao_form["authorizing_official-last_name"] = "Tester ATO"
|
||||||
|
# ao_form["authorizing_official-title"] = "Chief Tester"
|
||||||
|
# ao_form["authorizing_official-email"] = "testy@town.com"
|
||||||
|
|
||||||
your_contact_form["your_contact-first_name"] = "Testy you"
|
# # test next button
|
||||||
your_contact_form["your_contact-last_name"] = "Tester you"
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
your_contact_form["your_contact-title"] = "Admin Tester"
|
# ao_result = ao_form.submit()
|
||||||
your_contact_form["your_contact-email"] = "testy-admin@town.com"
|
# # validate that data from this step are being saved
|
||||||
your_contact_form["your_contact-phone"] = "(201) 555 5556"
|
# domain_request = DomainRequest.objects.get() # there's only one
|
||||||
|
# self.assertEqual(domain_request.authorizing_official.first_name, "Testy ATO")
|
||||||
|
# self.assertEqual(domain_request.authorizing_official.last_name, "Tester ATO")
|
||||||
|
# self.assertEqual(domain_request.authorizing_official.title, "Chief Tester")
|
||||||
|
# self.assertEqual(domain_request.authorizing_official.email, "testy@town.com")
|
||||||
|
# # the post request should return a redirect to the next form in
|
||||||
|
# # the domain request page
|
||||||
|
# self.assertEqual(ao_result.status_code, 302)
|
||||||
|
# self.assertEqual(ao_result["Location"], "/request/current_sites/")
|
||||||
|
# num_pages_tested += 1
|
||||||
|
|
||||||
# test next button
|
# # ---- CURRENT SITES PAGE ----
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
# # Follow the redirect to the next form page
|
||||||
your_contact_result = your_contact_form.submit()
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
# validate that data from this step are being saved
|
# current_sites_page = ao_result.follow()
|
||||||
domain_request = DomainRequest.objects.get() # there's only one
|
# current_sites_form = current_sites_page.forms[0]
|
||||||
self.assertEqual(domain_request.submitter.first_name, "Testy you")
|
# current_sites_form["current_sites-0-website"] = "www.city.com"
|
||||||
self.assertEqual(domain_request.submitter.last_name, "Tester you")
|
|
||||||
self.assertEqual(domain_request.submitter.title, "Admin Tester")
|
|
||||||
self.assertEqual(domain_request.submitter.email, "testy-admin@town.com")
|
|
||||||
self.assertEqual(domain_request.submitter.phone, "(201) 555 5556")
|
|
||||||
# the post request should return a redirect to the next form in
|
|
||||||
# the domain request page
|
|
||||||
self.assertEqual(your_contact_result.status_code, 302)
|
|
||||||
self.assertEqual(your_contact_result["Location"], "/request/other_contacts/")
|
|
||||||
num_pages_tested += 1
|
|
||||||
|
|
||||||
# ---- OTHER CONTACTS PAGE ----
|
# # test next button
|
||||||
# Follow the redirect to the next form page
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
# current_sites_result = current_sites_form.submit()
|
||||||
other_contacts_page = your_contact_result.follow()
|
# # validate that data from this step are being saved
|
||||||
|
# domain_request = DomainRequest.objects.get() # there's only one
|
||||||
|
# self.assertEqual(
|
||||||
|
# domain_request.current_websites.filter(website="http://www.city.com").count(),
|
||||||
|
# 1,
|
||||||
|
# )
|
||||||
|
# # the post request should return a redirect to the next form in
|
||||||
|
# # the domain request page
|
||||||
|
# self.assertEqual(current_sites_result.status_code, 302)
|
||||||
|
# self.assertEqual(current_sites_result["Location"], "/request/dotgov_domain/")
|
||||||
|
# num_pages_tested += 1
|
||||||
|
|
||||||
# This page has 3 forms in 1.
|
# # ---- DOTGOV DOMAIN PAGE ----
|
||||||
# Let's set the yes/no radios to enable the other contacts fieldsets
|
# # Follow the redirect to the next form page
|
||||||
other_contacts_form = other_contacts_page.forms[0]
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
# dotgov_page = current_sites_result.follow()
|
||||||
|
# dotgov_form = dotgov_page.forms[0]
|
||||||
|
# dotgov_form["dotgov_domain-requested_domain"] = "city"
|
||||||
|
# dotgov_form["dotgov_domain-0-alternative_domain"] = "city1"
|
||||||
|
|
||||||
other_contacts_form["other_contacts-has_other_contacts"] = "True"
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
# dotgov_result = dotgov_form.submit()
|
||||||
|
# # validate that data from this step are being saved
|
||||||
|
# domain_request = DomainRequest.objects.get() # there's only one
|
||||||
|
# self.assertEqual(domain_request.requested_domain.name, "city.gov")
|
||||||
|
# self.assertEqual(domain_request.alternative_domains.filter(website="city1.gov").count(), 1)
|
||||||
|
# # the post request should return a redirect to the next form in
|
||||||
|
# # the domain request page
|
||||||
|
# self.assertEqual(dotgov_result.status_code, 302)
|
||||||
|
# self.assertEqual(dotgov_result["Location"], "/request/purpose/")
|
||||||
|
# num_pages_tested += 1
|
||||||
|
|
||||||
other_contacts_form["other_contacts-0-first_name"] = "Testy2"
|
# # ---- PURPOSE PAGE ----
|
||||||
other_contacts_form["other_contacts-0-last_name"] = "Tester2"
|
# # Follow the redirect to the next form page
|
||||||
other_contacts_form["other_contacts-0-title"] = "Another Tester"
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
other_contacts_form["other_contacts-0-email"] = "testy2@town.com"
|
# purpose_page = dotgov_result.follow()
|
||||||
other_contacts_form["other_contacts-0-phone"] = "(201) 555 5557"
|
# purpose_form = purpose_page.forms[0]
|
||||||
|
# purpose_form["purpose-purpose"] = "For all kinds of things."
|
||||||
|
|
||||||
# test next button
|
# # test next button
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
other_contacts_result = other_contacts_form.submit()
|
# purpose_result = purpose_form.submit()
|
||||||
# validate that data from this step are being saved
|
# # validate that data from this step are being saved
|
||||||
domain_request = DomainRequest.objects.get() # there's only one
|
# domain_request = DomainRequest.objects.get() # there's only one
|
||||||
self.assertEqual(
|
# self.assertEqual(domain_request.purpose, "For all kinds of things.")
|
||||||
domain_request.other_contacts.filter(
|
# # the post request should return a redirect to the next form in
|
||||||
first_name="Testy2",
|
# # the domain request page
|
||||||
last_name="Tester2",
|
# self.assertEqual(purpose_result.status_code, 302)
|
||||||
title="Another Tester",
|
# self.assertEqual(purpose_result["Location"], "/request/your_contact/")
|
||||||
email="testy2@town.com",
|
# num_pages_tested += 1
|
||||||
phone="(201) 555 5557",
|
|
||||||
).count(),
|
|
||||||
1,
|
|
||||||
)
|
|
||||||
# the post request should return a redirect to the next form in
|
|
||||||
# the domain request page
|
|
||||||
self.assertEqual(other_contacts_result.status_code, 302)
|
|
||||||
self.assertEqual(other_contacts_result["Location"], "/request/additional_details/")
|
|
||||||
num_pages_tested += 1
|
|
||||||
|
|
||||||
# ---- ADDITIONAL DETAILS PAGE ----
|
# # ---- YOUR CONTACT INFO PAGE ----
|
||||||
# Follow the redirect to the next form page
|
# # Follow the redirect to the next form page
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
additional_details_page = other_contacts_result.follow()
|
# your_contact_page = purpose_result.follow()
|
||||||
additional_details_form = additional_details_page.forms[0]
|
# your_contact_form = your_contact_page.forms[0]
|
||||||
|
|
||||||
# load inputs with test data
|
# your_contact_form["your_contact-first_name"] = "Testy you"
|
||||||
|
# your_contact_form["your_contact-last_name"] = "Tester you"
|
||||||
|
# your_contact_form["your_contact-title"] = "Admin Tester"
|
||||||
|
# your_contact_form["your_contact-email"] = "testy-admin@town.com"
|
||||||
|
# your_contact_form["your_contact-phone"] = "(201) 555 5556"
|
||||||
|
|
||||||
additional_details_form["additional_details-has_cisa_representative"] = "True"
|
# # test next button
|
||||||
additional_details_form["additional_details-has_anything_else_text"] = "True"
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
additional_details_form["additional_details-cisa_representative_email"] = "FakeEmail@gmail.com"
|
# your_contact_result = your_contact_form.submit()
|
||||||
additional_details_form["additional_details-anything_else"] = "Nothing else."
|
# # validate that data from this step are being saved
|
||||||
|
# domain_request = DomainRequest.objects.get() # there's only one
|
||||||
|
# self.assertEqual(domain_request.submitter.first_name, "Testy you")
|
||||||
|
# self.assertEqual(domain_request.submitter.last_name, "Tester you")
|
||||||
|
# self.assertEqual(domain_request.submitter.title, "Admin Tester")
|
||||||
|
# self.assertEqual(domain_request.submitter.email, "testy-admin@town.com")
|
||||||
|
# self.assertEqual(domain_request.submitter.phone, "(201) 555 5556")
|
||||||
|
# # the post request should return a redirect to the next form in
|
||||||
|
# # the domain request page
|
||||||
|
# self.assertEqual(your_contact_result.status_code, 302)
|
||||||
|
# self.assertEqual(your_contact_result["Location"], "/request/other_contacts/")
|
||||||
|
# num_pages_tested += 1
|
||||||
|
|
||||||
# test next button
|
# # ---- OTHER CONTACTS PAGE ----
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
# # Follow the redirect to the next form page
|
||||||
additional_details_result = additional_details_form.submit()
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
# validate that data from this step are being saved
|
# other_contacts_page = your_contact_result.follow()
|
||||||
domain_request = DomainRequest.objects.get() # there's only one
|
|
||||||
self.assertEqual(domain_request.cisa_representative_email, "FakeEmail@gmail.com")
|
|
||||||
self.assertEqual(domain_request.anything_else, "Nothing else.")
|
|
||||||
# the post request should return a redirect to the next form in
|
|
||||||
# the domain request page
|
|
||||||
self.assertEqual(additional_details_result.status_code, 302)
|
|
||||||
self.assertEqual(additional_details_result["Location"], "/request/requirements/")
|
|
||||||
num_pages_tested += 1
|
|
||||||
|
|
||||||
# ---- REQUIREMENTS PAGE ----
|
# # This page has 3 forms in 1.
|
||||||
# Follow the redirect to the next form page
|
# # Let's set the yes/no radios to enable the other contacts fieldsets
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
# other_contacts_form = other_contacts_page.forms[0]
|
||||||
requirements_page = additional_details_result.follow()
|
|
||||||
requirements_form = requirements_page.forms[0]
|
|
||||||
|
|
||||||
requirements_form["requirements-is_policy_acknowledged"] = True
|
# other_contacts_form["other_contacts-has_other_contacts"] = "True"
|
||||||
|
|
||||||
# test next button
|
# other_contacts_form["other_contacts-0-first_name"] = "Testy2"
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
# other_contacts_form["other_contacts-0-last_name"] = "Tester2"
|
||||||
requirements_result = requirements_form.submit()
|
# other_contacts_form["other_contacts-0-title"] = "Another Tester"
|
||||||
# validate that data from this step are being saved
|
# other_contacts_form["other_contacts-0-email"] = "testy2@town.com"
|
||||||
domain_request = DomainRequest.objects.get() # there's only one
|
# other_contacts_form["other_contacts-0-phone"] = "(201) 555 5557"
|
||||||
self.assertEqual(domain_request.is_policy_acknowledged, True)
|
|
||||||
# the post request should return a redirect to the next form in
|
# # test next button
|
||||||
# the domain request page
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
self.assertEqual(requirements_result.status_code, 302)
|
# other_contacts_result = other_contacts_form.submit()
|
||||||
self.assertEqual(requirements_result["Location"], "/request/review/")
|
# # validate that data from this step are being saved
|
||||||
num_pages_tested += 1
|
# domain_request = DomainRequest.objects.get() # there's only one
|
||||||
|
# self.assertEqual(
|
||||||
|
# domain_request.other_contacts.filter(
|
||||||
|
# first_name="Testy2",
|
||||||
|
# last_name="Tester2",
|
||||||
|
# title="Another Tester",
|
||||||
|
# email="testy2@town.com",
|
||||||
|
# phone="(201) 555 5557",
|
||||||
|
# ).count(),
|
||||||
|
# 1,
|
||||||
|
# )
|
||||||
|
# # the post request should return a redirect to the next form in
|
||||||
|
# # the domain request page
|
||||||
|
# self.assertEqual(other_contacts_result.status_code, 302)
|
||||||
|
# self.assertEqual(other_contacts_result["Location"], "/request/additional_details/")
|
||||||
|
# num_pages_tested += 1
|
||||||
|
|
||||||
|
# # ---- ADDITIONAL DETAILS PAGE ----
|
||||||
|
# # Follow the redirect to the next form page
|
||||||
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
# additional_details_page = other_contacts_result.follow()
|
||||||
|
# additional_details_form = additional_details_page.forms[0]
|
||||||
|
|
||||||
|
# # load inputs with test data
|
||||||
|
|
||||||
|
# additional_details_form["additional_details-has_cisa_representative"] = "True"
|
||||||
|
# additional_details_form["additional_details-has_anything_else_text"] = "True"
|
||||||
|
# additional_details_form["additional_details-cisa_representative_email"] = "FakeEmail@gmail.com"
|
||||||
|
# additional_details_form["additional_details-anything_else"] = "Nothing else."
|
||||||
|
|
||||||
|
# # test next button
|
||||||
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
# additional_details_result = additional_details_form.submit()
|
||||||
|
# # validate that data from this step are being saved
|
||||||
|
# domain_request = DomainRequest.objects.get() # there's only one
|
||||||
|
# self.assertEqual(domain_request.cisa_representative_email, "FakeEmail@gmail.com")
|
||||||
|
# self.assertEqual(domain_request.anything_else, "Nothing else.")
|
||||||
|
# # the post request should return a redirect to the next form in
|
||||||
|
# # the domain request page
|
||||||
|
# self.assertEqual(additional_details_result.status_code, 302)
|
||||||
|
# self.assertEqual(additional_details_result["Location"], "/request/requirements/")
|
||||||
|
# num_pages_tested += 1
|
||||||
|
|
||||||
|
# # ---- REQUIREMENTS PAGE ----
|
||||||
|
# # Follow the redirect to the next form page
|
||||||
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
# requirements_page = additional_details_result.follow()
|
||||||
|
# requirements_form = requirements_page.forms[0]
|
||||||
|
|
||||||
|
# requirements_form["requirements-is_policy_acknowledged"] = True
|
||||||
|
|
||||||
|
# # test next button
|
||||||
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
# requirements_result = requirements_form.submit()
|
||||||
|
# # validate that data from this step are being saved
|
||||||
|
# domain_request = DomainRequest.objects.get() # there's only one
|
||||||
|
# self.assertEqual(domain_request.is_policy_acknowledged, True)
|
||||||
|
# # the post request should return a redirect to the next form in
|
||||||
|
# # the domain request page
|
||||||
|
# self.assertEqual(requirements_result.status_code, 302)
|
||||||
|
# self.assertEqual(requirements_result["Location"], "/request/review/")
|
||||||
|
# num_pages_tested += 1
|
||||||
|
|
||||||
# ---- REVIEW AND FINSIHED PAGES ----
|
# ---- REVIEW AND FINSIHED PAGES ----
|
||||||
# Follow the redirect to the next form page
|
# Follow the redirect to the next form page
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
review_page = requirements_result.follow()
|
# review_page = requirements_result.follow()
|
||||||
review_form = review_page.forms[0]
|
# review_form = review_page.forms[0]
|
||||||
print("$$$$$$$$$$$$$$$$$$$$$$", review_page)
|
# print("$$$$$$$$$$$$$$$$$$$$$$", review_page)
|
||||||
|
|
||||||
# Review page contains all the previously entered data
|
# # Review page contains all the previously entered data
|
||||||
# Let's make sure the long org name is displayed
|
# # Let's make sure the long org name is displayed
|
||||||
self.assertContains(review_page, "Incomplete")
|
# self.assertContains(review_page, "Incomplete")
|
||||||
# In theory we just need to check that tribal is incomplete
|
# In theory we just need to check that tribal is incomplete
|
||||||
# I don't need to re-look at any of these underneath
|
# I don't need to re-look at any of these underneath
|
||||||
# self.assertContains(review_page, "Executive")
|
# self.assertContains(review_page, "Executive")
|
||||||
|
@ -813,22 +848,22 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# And the existence of the modal's data parked and ready for the js init.
|
# And the existence of the modal's data parked and ready for the js init.
|
||||||
# The next assert also tests for the passed requested domain context from
|
# The next assert also tests for the passed requested domain context from
|
||||||
# the view > domain_request_form > modal
|
# the view > domain_request_form > modal
|
||||||
self.assertContains(review_page, "You can’t submit this request")
|
# self.assertContains(review_page, "You can’t submit this request")
|
||||||
|
|
||||||
# final submission results in a redirect to the "finished" URL
|
# # final submission results in a redirect to the "finished" URL
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
with less_console_noise():
|
# with less_console_noise():
|
||||||
review_result = review_form.submit()
|
# review_result = review_form.submit()
|
||||||
print("!!!!!!!!!!!!!!!!!!! review_result", review_result)
|
# print("!!!!!!!!!!!!!!!!!!! review_result", review_result)
|
||||||
|
|
||||||
print("!!!!!!!!!!!!!!!!!!! review_result.status_code", review_result.status_code)
|
# print("!!!!!!!!!!!!!!!!!!! review_result.status_code", review_result.status_code)
|
||||||
print("!!!!!!!!!!!!!!!!!!! review_results location", review_result["Location"])
|
# print("!!!!!!!!!!!!!!!!!!! review_results location", review_result["Location"])
|
||||||
|
|
||||||
self.assertEqual(review_result.status_code, 302)
|
# self.assertEqual(review_result.status_code, 302)
|
||||||
self.assertEqual(review_result["Location"], "/request/finished/")
|
# self.assertEqual(review_result["Location"], "/request/finished/")
|
||||||
|
|
||||||
# self.assertEqual(review_result["Location"], "/tribal_government/")
|
# # self.assertEqual(review_result["Location"], "/tribal_government/")
|
||||||
num_pages_tested += 1
|
# num_pages_tested += 1
|
||||||
|
|
||||||
# following this redirect is a GET request, so include the cookie
|
# following this redirect is a GET request, so include the cookie
|
||||||
# here too.
|
# here too.
|
||||||
|
@ -838,7 +873,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# self.assertContains(final_result, "Thanks for your domain request!")
|
# self.assertContains(final_result, "Thanks for your domain request!")
|
||||||
|
|
||||||
# check that any new pages are added to this test
|
# check that any new pages are added to this test
|
||||||
self.assertEqual(num_pages, num_pages_tested)
|
# self.assertEqual(num_pages, num_pages_tested)
|
||||||
|
|
||||||
# This is the start of a test to check an existing domain_request, it currently
|
# This is the start of a test to check an existing domain_request, it currently
|
||||||
# does not work and results in errors as noted in:
|
# does not work and results in errors as noted in:
|
||||||
|
|
|
@ -374,108 +374,109 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
||||||
}
|
}
|
||||||
return [key for key, value in history_dict.items() if value]
|
return [key for key, value in history_dict.items() if value]
|
||||||
|
|
||||||
def _is_federal_complete(self):
|
# def _is_federal_complete(self):
|
||||||
# Federal -> "Federal government branch" page can't be empty + Federal Agency selection can't be None
|
# # Federal -> "Federal government branch" page can't be empty + Federal Agency selection can't be None
|
||||||
return not (self.domain_request.federal_type is None or self.domain_request.federal_agency is None)
|
# return not (self.domain_request.federal_type is None or self.domain_request.federal_agency is None)
|
||||||
|
|
||||||
def _is_interstate_complete(self):
|
# def _is_interstate_complete(self):
|
||||||
# Interstate -> "About your organization" page can't be empty
|
# # Interstate -> "About your organization" page can't be empty
|
||||||
return self.domain_request.about_your_organization is not None
|
# return self.domain_request.about_your_organization is not None
|
||||||
|
|
||||||
def _is_state_or_territory_complete(self):
|
# def _is_state_or_territory_complete(self):
|
||||||
# State -> ""Election office" page can't be empty
|
# # State -> ""Election office" page can't be empty
|
||||||
return self.domain_request.is_election_board is not None
|
# return self.domain_request.is_election_board is not None
|
||||||
|
|
||||||
def _is_tribal_complete(self):
|
# def _is_tribal_complete(self):
|
||||||
# Tribal -> "Tribal name" and "Election office" page can't be empty
|
# # Tribal -> "Tribal name" and "Election office" page can't be empty
|
||||||
return self.domain_request.tribe_name is not None and self.domain_request.is_election_board is not None
|
# return self.domain_request.tribe_name is not None and self.domain_request.is_election_board is not None
|
||||||
|
|
||||||
def _is_county_complete(self):
|
# def _is_county_complete(self):
|
||||||
# County -> "Election office" page can't be empty
|
# # County -> "Election office" page can't be empty
|
||||||
return self.domain_request.is_election_board is not None
|
# return self.domain_request.is_election_board is not None
|
||||||
|
|
||||||
def _is_city_complete(self):
|
# def _is_city_complete(self):
|
||||||
# City -> "Election office" page can't be empty
|
# # City -> "Election office" page can't be empty
|
||||||
return self.domain_request.is_election_board is not None
|
# return self.domain_request.is_election_board is not None
|
||||||
|
|
||||||
def _is_special_district_complete(self):
|
# def _is_special_district_complete(self):
|
||||||
# Special District -> "Election office" and "About your organization" page can't be empty
|
# # Special District -> "Election office" and "About your organization" page can't be empty
|
||||||
return (
|
# return (
|
||||||
self.domain_request.is_election_board is not None
|
# self.domain_request.is_election_board is not None
|
||||||
and self.domain_request.about_your_organization is not None
|
# and self.domain_request.about_your_organization is not None
|
||||||
)
|
# )
|
||||||
|
|
||||||
def _is_organization_name_and_address_complete(self):
|
# def _is_organization_name_and_address_complete(self):
|
||||||
return not (
|
# return not (
|
||||||
self.domain_request.organization_name is None
|
# self.domain_request.organization_name is None
|
||||||
or self.domain_request.address_line1 is None
|
# or self.domain_request.address_line1 is None
|
||||||
or self.domain_request.city is None
|
# or self.domain_request.city is None
|
||||||
or self.domain_request.state_territory is None
|
# or self.domain_request.state_territory is None
|
||||||
or self.domain_request.zipcode is None
|
# or self.domain_request.zipcode is None
|
||||||
)
|
# )
|
||||||
|
|
||||||
def _is_authorizing_official_complete(self):
|
# def _is_authorizing_official_complete(self):
|
||||||
return self.domain_request.authorizing_official is not None
|
# return self.domain_request.authorizing_official is not None
|
||||||
|
|
||||||
def _is_requested_domain_complete(self):
|
# def _is_requested_domain_complete(self):
|
||||||
return self.domain_request.requested_domain is not None
|
# return self.domain_request.requested_domain is not None
|
||||||
|
|
||||||
def _is_purpose_complete(self):
|
# def _is_purpose_complete(self):
|
||||||
return self.domain_request.purpose is not None
|
# return self.domain_request.purpose is not None
|
||||||
|
|
||||||
def _is_submitter_complete(self):
|
# def _is_submitter_complete(self):
|
||||||
return self.domain_request.submitter is not None
|
# return self.domain_request.submitter is not None
|
||||||
|
|
||||||
def _is_other_contacts_complete(self):
|
# def _is_other_contacts_complete(self):
|
||||||
return self.domain_request.other_contacts is not None
|
# return self.domain_request.other_contacts is not None
|
||||||
|
|
||||||
def _is_additional_details_complete(self):
|
# def _is_additional_details_complete(self):
|
||||||
return not (
|
# return not (
|
||||||
self.domain_request.has_cisa_representative is None
|
# self.domain_request.has_cisa_representative is None
|
||||||
or self.domain_request.has_anything_else_text is None
|
# or self.domain_request.has_anything_else_text is None
|
||||||
# RARE EDGE CASE: You click yes on having a cisa rep, but you dont type in email (should block in form)
|
# # RARE EDGE CASE: You click yes on having a cisa rep, but you dont type in email (should block in form)
|
||||||
or (
|
# or (
|
||||||
self.domain_request.has_cisa_representative is True
|
# self.domain_request.has_cisa_representative is True
|
||||||
and self.domain_request.cisa_representative_email is None
|
# and self.domain_request.cisa_representative_email is None
|
||||||
)
|
# )
|
||||||
or self.domain_request.is_policy_acknowledged is None
|
# or self.domain_request.is_policy_acknowledged is None
|
||||||
)
|
# )
|
||||||
|
|
||||||
def _is_general_form_complete(self):
|
# def _is_general_form_complete(self):
|
||||||
return (
|
# return (
|
||||||
self._is_organization_name_and_address_complete()
|
# self._is_organization_name_and_address_complete()
|
||||||
and self._is_authorizing_official_complete()
|
# and self._is_authorizing_official_complete()
|
||||||
and self._is_requested_domain_complete()
|
# and self._is_requested_domain_complete()
|
||||||
and self._is_purpose_complete()
|
# and self._is_purpose_complete()
|
||||||
and self._is_submitter_complete()
|
# and self._is_submitter_complete()
|
||||||
and self._is_other_contacts_complete()
|
# and self._is_other_contacts_complete()
|
||||||
and self._is_additional_details_complete()
|
# and self._is_additional_details_complete()
|
||||||
)
|
# )
|
||||||
|
|
||||||
def _form_complete(self):
|
# def _form_complete(self):
|
||||||
if self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.FEDERAL:
|
# if self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.FEDERAL:
|
||||||
is_complete = self._is_federal_complete()
|
# is_complete = self._is_federal_complete()
|
||||||
elif self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.INTERSTATE:
|
# elif self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.INTERSTATE:
|
||||||
is_complete = self._is_interstate_complete()
|
# is_complete = self._is_interstate_complete()
|
||||||
elif self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.STATE_OR_TERRITORY:
|
# elif self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.STATE_OR_TERRITORY:
|
||||||
is_complete = self._is_state_or_territory_complete()
|
# is_complete = self._is_state_or_territory_complete()
|
||||||
elif self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.TRIBAL:
|
# elif self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.TRIBAL:
|
||||||
is_complete = self._is_tribal_complete()
|
# is_complete = self._is_tribal_complete()
|
||||||
elif self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.COUNTY:
|
# elif self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.COUNTY:
|
||||||
is_complete = self._is_county_complete()
|
# is_complete = self._is_county_complete()
|
||||||
elif self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.CITY:
|
# elif self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.CITY:
|
||||||
is_complete = self._is_city_complete()
|
# is_complete = self._is_city_complete()
|
||||||
elif self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.SPECIAL_DISTRICT:
|
# elif self.domain_request.generic_org_type == DomainRequest.OrganizationChoices.SPECIAL_DISTRICT:
|
||||||
is_complete = self._is_special_district_complete()
|
# is_complete = self._is_special_district_complete()
|
||||||
else:
|
# else:
|
||||||
is_complete = False
|
# # NOTE: This shouldn't happen, this is only if somehow they didn't choose an org type
|
||||||
|
# is_complete = False
|
||||||
|
|
||||||
if not is_complete or not self._is_general_form_complete():
|
# if not is_complete or not self._is_general_form_complete():
|
||||||
print("!!!! We are in the False if statement - form is not complete")
|
# print("!!!! We are in the False if statement - form is not complete")
|
||||||
return False
|
# return False
|
||||||
|
|
||||||
print("!!!! We are in the True if statement - form is complete")
|
# print("!!!! We are in the True if statement - form is complete")
|
||||||
return True
|
# return True
|
||||||
|
|
||||||
def get_context_data(self):
|
def get_context_data(self):
|
||||||
"""Define context for access on all wizard pages."""
|
"""Define context for access on all wizard pages."""
|
||||||
|
@ -483,7 +484,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
||||||
# Concatenate the modal header that we'll pass to the modal.
|
# Concatenate the modal header that we'll pass to the modal.
|
||||||
|
|
||||||
context_stuff = {}
|
context_stuff = {}
|
||||||
if self._form_complete():
|
if DomainRequest._form_complete(self.domain_request):
|
||||||
print("!!!!!!!in form complete section")
|
print("!!!!!!!in form complete section")
|
||||||
modal_button = '<button type="submit" ' 'class="usa-button" ' ">Submit request</button>"
|
modal_button = '<button type="submit" ' 'class="usa-button" ' ">Submit request</button>"
|
||||||
context_stuff = {
|
context_stuff = {
|
||||||
|
@ -773,7 +774,7 @@ class Review(DomainRequestWizard):
|
||||||
forms = [] # type: ignore
|
forms = [] # type: ignore
|
||||||
|
|
||||||
def get_context_data(self):
|
def get_context_data(self):
|
||||||
if self._form_complete() is False:
|
if DomainRequest._form_complete(self.domain_request) is False:
|
||||||
logger.warning("User arrived at review page with an incomplete form.")
|
logger.warning("User arrived at review page with an incomplete form.")
|
||||||
context = super().get_context_data()
|
context = super().get_context_data()
|
||||||
context["Step"] = Step.__members__
|
context["Step"] = Step.__members__
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue