mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-18 10:29:23 +02:00
fixed unit tests (still need to rethink how to handle deletion of CISA rep contacts)
This commit is contained in:
parent
d9cc947f6e
commit
7dc9dba833
6 changed files with 41 additions and 27 deletions
|
@ -369,7 +369,9 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
|
||||
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-first_name"] = "CISA-first-name"
|
||||
additional_details_form["additional_details-last_name"] = "CISA-last-name"
|
||||
additional_details_form["additional_details-email"] = "FakeEmail@gmail.com"
|
||||
additional_details_form["additional_details-anything_else"] = "Nothing else."
|
||||
|
||||
# test next button
|
||||
|
@ -377,7 +379,9 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
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.cisa_representative.first_name, "CISA-first-name")
|
||||
self.assertEqual(domain_request.cisa_representative.last_name, "CISA-last-name")
|
||||
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
|
||||
|
@ -814,8 +818,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
for both yes/no radios if the domain request has a value for cisa_representative and
|
||||
anything_else"""
|
||||
|
||||
domain_request = completed_domain_request(user=self.user, has_anything_else=True)
|
||||
domain_request.cisa_representative_email = "test@igorville.gov"
|
||||
domain_request = completed_domain_request(user=self.user, has_anything_else=True, has_cisa_representative=True)
|
||||
domain_request.anything_else = "1234"
|
||||
domain_request.save()
|
||||
|
||||
|
@ -867,12 +870,11 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
"""On the Additional details page, the form preselects "no" when has_cisa_representative
|
||||
and anything_else is no"""
|
||||
|
||||
domain_request = completed_domain_request(user=self.user, has_anything_else=False)
|
||||
domain_request = completed_domain_request(user=self.user, has_anything_else=False, has_cisa_representative=False)
|
||||
|
||||
# Unlike the other contacts form, the no button is tracked with these boolean fields.
|
||||
# This means that we should expect this to correlate with the no button.
|
||||
domain_request.has_anything_else_text = False
|
||||
domain_request.has_cisa_representative = False
|
||||
domain_request.save()
|
||||
|
||||
# prime the form by visiting /edit
|
||||
|
@ -891,7 +893,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
|
||||
# Check the cisa representative yes/no field
|
||||
yes_no_cisa = additional_details_form["additional_details-has_cisa_representative"].value
|
||||
self.assertEquals(yes_no_cisa, "False")
|
||||
self.assertEquals(yes_no_cisa, None)
|
||||
|
||||
# Check the anything else yes/no field
|
||||
yes_no_anything_else = additional_details_form["additional_details-has_anything_else_text"].value
|
||||
|
@ -901,12 +903,16 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
"""When a user submits the Additional Details form with no selected for all fields,
|
||||
the domain request's data gets wiped when submitted"""
|
||||
domain_request = completed_domain_request(name="nocisareps.gov", user=self.user)
|
||||
domain_request.cisa_representative_email = "fake@faketown.gov"
|
||||
domain_request.cisa_representative.first_name = "cisa-firstname1"
|
||||
domain_request.cisa_representative.last_name = "cisa-lastname1"
|
||||
domain_request.cisa_representative.email = "fake@faketown.gov"
|
||||
domain_request.save()
|
||||
|
||||
# Make sure we have the data we need for the test
|
||||
self.assertEqual(domain_request.anything_else, "There is more")
|
||||
self.assertEqual(domain_request.cisa_representative_email, "fake@faketown.gov")
|
||||
self.assertEqual(domain_request.cisa_representative.first_name, "cisa-firstname1")
|
||||
self.assertEqual(domain_request.cisa_representative.last_name, "cisa-lastname1")
|
||||
self.assertEqual(domain_request.cisa_representative.email, "fake@faketown.gov")
|
||||
|
||||
# prime the form by visiting /edit
|
||||
self.app.get(reverse("edit-domain-request", kwargs={"id": domain_request.pk}))
|
||||
|
@ -944,7 +950,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
|
||||
# Check that our data has been cleared
|
||||
self.assertEqual(domain_request.anything_else, None)
|
||||
self.assertEqual(domain_request.cisa_representative_email, None)
|
||||
self.assertEqual(domain_request.cisa_representative, None)
|
||||
|
||||
# Double check the yes/no fields
|
||||
self.assertEqual(domain_request.has_anything_else_text, False)
|
||||
|
@ -953,11 +959,11 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
def test_submitting_additional_details_populates_cisa_representative_and_anything_else(self):
|
||||
"""When a user submits the Additional Details form,
|
||||
the domain request's data gets submitted"""
|
||||
domain_request = completed_domain_request(name="cisareps.gov", user=self.user, has_anything_else=False)
|
||||
domain_request = completed_domain_request(name="cisareps.gov", user=self.user, has_anything_else=False, has_cisa_representative=False)
|
||||
|
||||
# Make sure we have the data we need for the test
|
||||
self.assertEqual(domain_request.anything_else, None)
|
||||
self.assertEqual(domain_request.cisa_representative_email, None)
|
||||
self.assertEqual(domain_request.cisa_representative, None)
|
||||
|
||||
# These fields should not be selected at all, since we haven't initialized the form yet
|
||||
self.assertEqual(domain_request.has_anything_else_text, None)
|
||||
|
@ -980,7 +986,9 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
# Set fields to true, and set data on those fields
|
||||
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"] = "test@faketest.gov"
|
||||
additional_details_form["additional_details-first_name"] = "cisa-firstname"
|
||||
additional_details_form["additional_details-last_name"] = "cisa-lastname"
|
||||
additional_details_form["additional_details-email"] = "test@faketest.gov"
|
||||
additional_details_form["additional_details-anything_else"] = "redandblue"
|
||||
|
||||
# Submit the form
|
||||
|
@ -992,14 +1000,16 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
domain_request = DomainRequest.objects.get(requested_domain__name="cisareps.gov")
|
||||
|
||||
self.assertEqual(domain_request.anything_else, "redandblue")
|
||||
self.assertEqual(domain_request.cisa_representative_email, "test@faketest.gov")
|
||||
self.assertEqual(domain_request.cisa_representative.first_name, "cisa-firstname")
|
||||
self.assertEqual(domain_request.cisa_representative.last_name, "cisa-lastname")
|
||||
self.assertEqual(domain_request.cisa_representative.email, "test@faketest.gov")
|
||||
|
||||
self.assertEqual(domain_request.has_cisa_representative, True)
|
||||
self.assertEqual(domain_request.has_anything_else_text, True)
|
||||
|
||||
def test_if_cisa_representative_yes_no_form_is_yes_then_field_is_required(self):
|
||||
"""Applicants with a cisa representative must provide a value"""
|
||||
domain_request = completed_domain_request(name="cisareps.gov", user=self.user, has_anything_else=False)
|
||||
domain_request = completed_domain_request(name="cisareps.gov", user=self.user, has_anything_else=False, has_cisa_representative=False)
|
||||
|
||||
# prime the form by visiting /edit
|
||||
self.app.get(reverse("edit-domain-request", kwargs={"id": domain_request.pk}))
|
||||
|
@ -1024,7 +1034,8 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
|
||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||
|
||||
self.assertContains(response, "Enter the email address of your CISA regional representative.")
|
||||
self.assertContains(response, "Enter your first name / given name.")
|
||||
self.assertContains(response, "Enter your last name / family name.")
|
||||
|
||||
def test_if_anything_else_yes_no_form_is_yes_then_field_is_required(self):
|
||||
"""Applicants with a anything else must provide a value"""
|
||||
|
@ -1059,7 +1070,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
def test_additional_details_form_fields_required(self):
|
||||
"""When a user submits the Additional Details form without checking the
|
||||
has_cisa_representative and has_anything_else_text fields, the form should deny this action"""
|
||||
domain_request = completed_domain_request(name="cisareps.gov", user=self.user, has_anything_else=False)
|
||||
domain_request = completed_domain_request(name="cisareps.gov", user=self.user, has_anything_else=False, has_cisa_representative=False)
|
||||
|
||||
self.assertEqual(domain_request.has_anything_else_text, None)
|
||||
self.assertEqual(domain_request.has_cisa_representative, None)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue