mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-15 17:17:02 +02:00
Some unit tests
This commit is contained in:
parent
9931fcc4d3
commit
7b19e29cf6
4 changed files with 49 additions and 5 deletions
|
@ -219,7 +219,6 @@ class DomainInformation(TimeStampedModel):
|
||||||
cisa_representative_email = models.EmailField(
|
cisa_representative_email = models.EmailField(
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
db_index=True,
|
|
||||||
verbose_name="CISA region representative",
|
verbose_name="CISA region representative",
|
||||||
max_length=320,
|
max_length=320,
|
||||||
)
|
)
|
||||||
|
|
|
@ -659,7 +659,6 @@ class DomainRequest(TimeStampedModel):
|
||||||
cisa_representative_email = models.EmailField(
|
cisa_representative_email = models.EmailField(
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
db_index=True,
|
|
||||||
verbose_name="CISA region representative",
|
verbose_name="CISA region representative",
|
||||||
max_length=320,
|
max_length=320,
|
||||||
)
|
)
|
||||||
|
@ -739,7 +738,7 @@ class DomainRequest(TimeStampedModel):
|
||||||
self.cisa_representative_email != "" and self.cisa_representative_email is not None
|
self.cisa_representative_email != "" and self.cisa_representative_email is not None
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.anything_else is not None:
|
if self.has_anything_else_text is not None:
|
||||||
self.has_anything_else_text = self.anything_else != "" and self.anything_else is not None
|
self.has_anything_else_text = self.anything_else != "" and self.anything_else is not None
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|
|
@ -857,6 +857,8 @@ def completed_domain_request(
|
||||||
creator=user,
|
creator=user,
|
||||||
status=status,
|
status=status,
|
||||||
investigator=investigator,
|
investigator=investigator,
|
||||||
|
has_cisa_representative=False,
|
||||||
|
has_anything_else_text=False,
|
||||||
)
|
)
|
||||||
if has_about_your_organization:
|
if has_about_your_organization:
|
||||||
domain_request_kwargs["about_your_organization"] = "e-Government"
|
domain_request_kwargs["about_your_organization"] = "e-Government"
|
||||||
|
|
|
@ -724,14 +724,26 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
|
|
||||||
self.assertContains(contact_page, self.TITLES[Step.ABOUT_YOUR_ORGANIZATION])
|
self.assertContains(contact_page, self.TITLES[Step.ABOUT_YOUR_ORGANIZATION])
|
||||||
|
|
||||||
def test_yes_no_form_inits_blank_for_new_domain_request(self):
|
def test_yes_no_contact_form_inits_blank_for_new_domain_request(self):
|
||||||
"""On the Other Contacts page, the yes/no form gets initialized with nothing selected for
|
"""On the Other Contacts page, the yes/no form gets initialized with nothing selected for
|
||||||
new domain requests"""
|
new domain requests"""
|
||||||
other_contacts_page = self.app.get(reverse("domain-request:other_contacts"))
|
other_contacts_page = self.app.get(reverse("domain-request:other_contacts"))
|
||||||
other_contacts_form = other_contacts_page.forms[0]
|
other_contacts_form = other_contacts_page.forms[0]
|
||||||
self.assertEquals(other_contacts_form["other_contacts-has_other_contacts"].value, None)
|
self.assertEquals(other_contacts_form["other_contacts-has_other_contacts"].value, None)
|
||||||
|
|
||||||
def test_yes_no_form_inits_yes_for_domain_request_with_other_contacts(self):
|
def test_yes_no_additional_form_inits_blank_for_new_domain_request(self):
|
||||||
|
"""On the Additional Details page, the yes/no form gets initialized with nothing selected for
|
||||||
|
new domain requests"""
|
||||||
|
additional_details_page = self.app.get(reverse("domain-request:additional_details"))
|
||||||
|
additional_form = additional_details_page.forms[0]
|
||||||
|
|
||||||
|
# Check the cisa representative yes/no field
|
||||||
|
self.assertEquals(additional_form["additional_details-has_cisa_representative"].value, None)
|
||||||
|
|
||||||
|
# Check the anything else yes/no field
|
||||||
|
self.assertEquals(additional_form["additional_details-has_anything_else_text"].value, None)
|
||||||
|
|
||||||
|
def test_yes_no_contact_form_inits_yes_for_domain_request_with_other_contacts(self):
|
||||||
"""On the Other Contacts page, the yes/no form gets initialized with YES selected if the
|
"""On the Other Contacts page, the yes/no form gets initialized with YES selected if the
|
||||||
domain request has other contacts"""
|
domain request has other contacts"""
|
||||||
# Domain Request has other contacts by default
|
# Domain Request has other contacts by default
|
||||||
|
@ -751,6 +763,38 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
other_contacts_form = other_contacts_page.forms[0]
|
other_contacts_form = other_contacts_page.forms[0]
|
||||||
self.assertEquals(other_contacts_form["other_contacts-has_other_contacts"].value, "True")
|
self.assertEquals(other_contacts_form["other_contacts-has_other_contacts"].value, "True")
|
||||||
|
|
||||||
|
def test_yes_no_additional_form_inits_yes_for_cisa_representative_and_anything_else(self):
|
||||||
|
"""On the Additional Details page, the yes/no form gets initialized with YES selected
|
||||||
|
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.anything_else="1234"
|
||||||
|
domain_request.save()
|
||||||
|
|
||||||
|
# prime the form by visiting /edit
|
||||||
|
self.app.get(reverse("edit-domain-request", kwargs={"id": domain_request.pk}))
|
||||||
|
# django-webtest does not handle cookie-based sessions well because it keeps
|
||||||
|
# resetting the session key on each new request, thus destroying the concept
|
||||||
|
# of a "session". We are going to do it manually, saving the session ID here
|
||||||
|
# and then setting the cookie on each request.
|
||||||
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
|
additional_details_page = self.app.get(reverse("domain-request:additional_details"))
|
||||||
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
|
additional_details_form = additional_details_page.forms[0]
|
||||||
|
|
||||||
|
# Check the cisa representative yes/no field
|
||||||
|
yes_no_cisa = additional_details_form["additional_details-has_cisa_representative"].value
|
||||||
|
self.assertEquals(yes_no_cisa, True)
|
||||||
|
|
||||||
|
# Check the anything else yes/no field
|
||||||
|
yes_no_anything_else = additional_details_form["additional_details-has_anything_else_text"].value
|
||||||
|
self.assertEquals(yes_no_anything_else, True)
|
||||||
|
|
||||||
def test_yes_no_form_inits_no_for_domain_request_with_no_other_contacts_rationale(self):
|
def test_yes_no_form_inits_no_for_domain_request_with_no_other_contacts_rationale(self):
|
||||||
"""On the Other Contacts page, the yes/no form gets initialized with NO selected if the
|
"""On the Other Contacts page, the yes/no form gets initialized with NO selected if the
|
||||||
domain request has no other contacts"""
|
domain request has no other contacts"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue