mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-18 18:39:21 +02:00
Add in other contacts rationale check and clean up tests
This commit is contained in:
parent
fa1fcba49a
commit
9f2a9594f6
4 changed files with 22 additions and 30 deletions
|
@ -989,7 +989,7 @@ class DomainRequest(TimeStampedModel):
|
|||
return self.submitter is not None
|
||||
|
||||
def _is_other_contacts_complete(self):
|
||||
# If the object even exists and double check for
|
||||
# If the object even exists and double check each part is filled out
|
||||
if (
|
||||
self.has_other_contacts()
|
||||
and self.other_contacts.filter(
|
||||
|
@ -999,6 +999,8 @@ class DomainRequest(TimeStampedModel):
|
|||
email__isnull=False,
|
||||
phone__isnull=False,
|
||||
).exists()
|
||||
# Radio button is No + has rationale
|
||||
or (self.has_other_contacts() is False and self.no_other_contacts_rationale is not None)
|
||||
):
|
||||
return True
|
||||
return False
|
||||
|
@ -1030,7 +1032,7 @@ class DomainRequest(TimeStampedModel):
|
|||
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_other_contacts_complete() # -- ISSUE HERE
|
||||
and self._is_additional_details_complete()
|
||||
and self._is_policy_acknowledgement_complete()
|
||||
)
|
||||
|
@ -1055,8 +1057,6 @@ class DomainRequest(TimeStampedModel):
|
|||
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
|
||||
|
|
|
@ -1655,6 +1655,7 @@ class TestDomainRequestIncomplete(TestCase):
|
|||
requested_domain=draft_domain,
|
||||
purpose="Some purpose",
|
||||
submitter=you,
|
||||
no_other_contacts_rationale=None,
|
||||
has_cisa_representative=True,
|
||||
cisa_representative_email="somerep@cisa.com",
|
||||
has_anything_else_text=True,
|
||||
|
@ -1781,10 +1782,24 @@ class TestDomainRequestIncomplete(TestCase):
|
|||
contact.save()
|
||||
self.assertFalse(self.domain_request._is_other_contacts_complete())
|
||||
|
||||
def test_is_other_contacts_complete(self):
|
||||
def test_is_other_contacts_complete_all_none(self):
|
||||
self.domain_request.other_contacts.clear()
|
||||
self.assertFalse(self.domain_request._is_other_contacts_complete())
|
||||
|
||||
def test_is_other_contacts_False_and_has_rationale(self):
|
||||
# Click radio button "No" for no other contacts and give rationale
|
||||
self.domain_request.other_contacts.clear()
|
||||
self.domain_request.other_contacts.exists = False
|
||||
self.domain_request.no_other_contacts_rationale = "Some rationale"
|
||||
self.assertTrue(self.domain_request._is_other_contacts_complete())
|
||||
|
||||
def test_is_other_contacts_False_and_NO_rationale(self):
|
||||
# Click radio button "No" for no other contacts and DONT give rationale
|
||||
self.domain_request.other_contacts.clear()
|
||||
self.domain_request.other_contacts.exists = False
|
||||
self.domain_request.no_other_contacts_rationale = None
|
||||
self.assertFalse(self.domain_request._is_other_contacts_complete())
|
||||
|
||||
def test_is_additional_details_complete(self):
|
||||
test_cases = [
|
||||
# CISA Rep - Yes
|
||||
|
|
|
@ -473,9 +473,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
@boto3_mocking.patching
|
||||
def test_domain_request_form_submission_incomplete(self):
|
||||
num_pages_tested = 0
|
||||
# elections, type_of_work, tribal_government
|
||||
SKIPPED_PAGES = 3
|
||||
# num_pages = len(self.TITLES) - SKIPPED_PAGES
|
||||
# skipping elections, type_of_work, tribal_government
|
||||
|
||||
intro_page = self.app.get(reverse("domain-request:"))
|
||||
# django-webtest does not handle cookie-based sessions well because it keeps
|
||||
|
@ -772,7 +770,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
# Follow the redirect to the next form page
|
||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||
review_page = requirements_result.follow()
|
||||
review_form = review_page.forms[0]
|
||||
# review_form = review_page.forms[0]
|
||||
|
||||
# Review page contains all the previously entered data
|
||||
# Let's make sure the long org name is displayed
|
||||
|
@ -789,24 +787,6 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
self.assertNotContains(review_page, "You are about to submit a domain request for city.gov")
|
||||
self.assertContains(review_page, "You can’t submit this request because it’s incomplete.")
|
||||
|
||||
# DO WE NEED TO BLOCK SUBMISSIONS WITH INCOMPLETE FORMS ON THE BACKEND @Alysia?
|
||||
|
||||
# final submission results in a redirect to the "finished" URL
|
||||
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||
# with less_console_noise():
|
||||
# review_result = review_form.submit()
|
||||
|
||||
# self.assertEqual(review_result.status_code, 302)
|
||||
# self.assertEqual(review_result["Location"], "/request/finished/")
|
||||
# num_pages_tested += 1
|
||||
|
||||
# # following this redirect is a GET request, so include the cookie
|
||||
# # here too.
|
||||
# self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||
# with less_console_noise():
|
||||
# final_result = review_result.follow()
|
||||
# self.assertContains(final_result, "Thanks for your domain request!")
|
||||
|
||||
# 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:
|
||||
# https://github.com/cisagov/getgov/pull/728
|
||||
|
|
|
@ -381,12 +381,10 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
|||
|
||||
context_stuff = {}
|
||||
if DomainRequest._form_complete(self.domain_request):
|
||||
print("!!!!!!!in form complete section")
|
||||
modal_button = '<button type="submit" ' 'class="usa-button" ' ">Submit request</button>"
|
||||
context_stuff = {
|
||||
"form_titles": self.TITLES,
|
||||
"steps": self.steps,
|
||||
# Add information about which steps should be unlocked
|
||||
"visited": self.storage.get("step_history", []),
|
||||
"is_federal": self.domain_request.is_federal(),
|
||||
"modal_button": modal_button,
|
||||
|
@ -397,7 +395,6 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
|||
"review_form_is_complete": True,
|
||||
}
|
||||
else: # form is not complete
|
||||
print("!!!!!!! form is not complete")
|
||||
modal_button = '<button type="button" ' 'class="usa-button" ' " data-close-modal>Return to request</button>"
|
||||
context_stuff = {
|
||||
"form_titles": self.TITLES,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue