mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-28 16:29:54 +02:00
Updated unit tests
This commit is contained in:
parent
3118ed210b
commit
59db36a751
2 changed files with 75 additions and 29 deletions
|
@ -556,16 +556,14 @@ class DomainRequest(TimeStampedModel):
|
|||
"""
|
||||
|
||||
# This ensures that if we have prefilled data, the form is prepopulated
|
||||
# NOTE: this relies on the fact that the first and last names of a CISA representative
|
||||
# are required fields. Because of this, we can simplify the check to only look at the
|
||||
# first name to determine whether or not a CISA representative was provided.
|
||||
if self.cisa_representative_first_name is not None:
|
||||
self.has_cisa_representative = self.cisa_representative_first_name != ""
|
||||
|
||||
if self.cisa_representative_first_name is not None or self.cisa_representative_last_name is not None:
|
||||
self.has_cisa_representative = self.cisa_representative_first_name != "" and self.cisa_representative_last_name != ""
|
||||
|
||||
# This check is required to ensure that the form doesn't start out checked
|
||||
if self.has_cisa_representative is not None:
|
||||
self.has_cisa_representative = (
|
||||
self.cisa_representative_first_name != "" and self.cisa_representative_first_name is not None
|
||||
(self.cisa_representative_first_name != "" and self.cisa_representative_first_name is not None)
|
||||
and (self.cisa_representative_last_name != "" and self.cisa_representative_last_name is not None)
|
||||
)
|
||||
|
||||
# This ensures that if we have prefilled data, the form is prepopulated
|
||||
|
@ -1034,12 +1032,14 @@ class DomainRequest(TimeStampedModel):
|
|||
return True
|
||||
return False
|
||||
|
||||
def _cisa_rep_and_email_check(self):
|
||||
# Has a CISA rep + email is NOT empty or NOT an empty string OR doesn't have CISA rep
|
||||
def _cisa_rep_check(self):
|
||||
# Either does not have a CISA rep, OR has a CISA rep + both first name and last name are NOT empty and are NOT an empty string
|
||||
return (
|
||||
self.has_cisa_representative is True
|
||||
and self.cisa_representative_email is not None
|
||||
and self.cisa_representative_email != ""
|
||||
and self.cisa_representative_first_name is not None
|
||||
and self.cisa_representative_first_name != ""
|
||||
and self.cisa_representative_last_name is not None
|
||||
and self.cisa_representative_last_name != ""
|
||||
) or self.has_cisa_representative is False
|
||||
|
||||
def _anything_else_radio_button_and_text_field_check(self):
|
||||
|
@ -1049,7 +1049,7 @@ class DomainRequest(TimeStampedModel):
|
|||
) or self.has_anything_else_text is False
|
||||
|
||||
def _is_additional_details_complete(self):
|
||||
return self._cisa_rep_and_email_check() and self._anything_else_radio_button_and_text_field_check()
|
||||
return self._cisa_rep_check() and self._anything_else_radio_button_and_text_field_check()
|
||||
|
||||
def _is_policy_acknowledgement_complete(self):
|
||||
return self.is_policy_acknowledged is not None
|
||||
|
|
|
@ -1800,93 +1800,129 @@ class TestDomainRequestIncomplete(TestCase):
|
|||
def test_is_additional_details_complete(self):
|
||||
test_cases = [
|
||||
# CISA Rep - Yes
|
||||
# Firstname - Yes
|
||||
# Lastname - Yes
|
||||
# Email - Yes
|
||||
# Anything Else Radio - Yes
|
||||
# Anything Else Text - Yes
|
||||
{
|
||||
"has_cisa_representative": True,
|
||||
"cisa_representative_first_name": "cisa-first-name",
|
||||
"cisa_representative_last_name": "cisa-last-name",
|
||||
"cisa_representative_email": "some@cisarepemail.com",
|
||||
"has_anything_else_text": True,
|
||||
"anything_else": "Some text",
|
||||
"expected": True,
|
||||
},
|
||||
# CISA Rep - Yes
|
||||
# Firstname - Yes
|
||||
# Lastname - Yes
|
||||
# Email - Yes
|
||||
# Anything Else Radio - Yes
|
||||
# Anything Else Text - None
|
||||
{
|
||||
"has_cisa_representative": True,
|
||||
"cisa_representative_first_name": "cisa-first-name",
|
||||
"cisa_representative_last_name": "cisa-last-name",
|
||||
"cisa_representative_email": "some@cisarepemail.com",
|
||||
"has_anything_else_text": True,
|
||||
"anything_else": None,
|
||||
"expected": True,
|
||||
},
|
||||
# CISA Rep - Yes
|
||||
# Email - Yes
|
||||
# Firstname - Yes
|
||||
# Lastname - Yes
|
||||
# Email - None >> e-mail is optional so it should not change anything setting this to None
|
||||
# Anything Else Radio - No
|
||||
# Anything Else Text - No
|
||||
{
|
||||
"has_cisa_representative": True,
|
||||
"cisa_representative_email": "some@cisarepemail.com",
|
||||
"cisa_representative_first_name": "cisa-first-name",
|
||||
"cisa_representative_last_name": "cisa-last-name",
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": False,
|
||||
"anything_else": None,
|
||||
"expected": True,
|
||||
},
|
||||
# CISA Rep - Yes
|
||||
# Email - Yes
|
||||
# Anything Else Radio - None
|
||||
# Anything Else Text - None
|
||||
{
|
||||
"has_cisa_representative": True,
|
||||
"cisa_representative_email": "some@cisarepemail.com",
|
||||
"has_anything_else_text": None,
|
||||
"anything_else": None,
|
||||
"expected": False,
|
||||
},
|
||||
# CISA Rep - Yes
|
||||
# Firstname - Yes
|
||||
# Lastname - Yes
|
||||
# Email - None
|
||||
# Anything Else Radio - None
|
||||
# Anything Else Text - None
|
||||
{
|
||||
"has_cisa_representative": True,
|
||||
"cisa_representative_first_name": "cisa-first-name",
|
||||
"cisa_representative_last_name": "cisa-last-name",
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": None,
|
||||
"anything_else": None,
|
||||
"expected": False,
|
||||
},
|
||||
# CISA Rep - Yes
|
||||
# Firstname - None
|
||||
# Lastname - None
|
||||
# Email - None
|
||||
# Anything Else Radio - None
|
||||
# Anything Else Text - None
|
||||
{
|
||||
"has_cisa_representative": True,
|
||||
"cisa_representative_first_name": None,
|
||||
"cisa_representative_last_name": None,
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": None,
|
||||
"anything_else": None,
|
||||
"expected": False,
|
||||
},
|
||||
# CISA Rep - Yes
|
||||
# Firstname - None
|
||||
# Lastname - None
|
||||
# Email - None
|
||||
# Anything Else Radio - No
|
||||
# Anything Else Text - No
|
||||
# sync_yes_no will override has_cisa_representative to be False if cisa_representative_email is None
|
||||
# sync_yes_no will override has_cisa_representative to be False if cisa_representative_first_name is None
|
||||
# therefore, our expected will be True
|
||||
{
|
||||
"has_cisa_representative": True,
|
||||
# Above will be overridden to False if cisa_rep_email is None bc of sync_yes_no_form_fields
|
||||
# Above will be overridden to False if cisa_representative_first_name is None bc of sync_yes_no_form_fields
|
||||
"cisa_representative_first_name": None,
|
||||
"cisa_representative_last_name": None,
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": False,
|
||||
"anything_else": None,
|
||||
"expected": True,
|
||||
},
|
||||
# CISA Rep - Yes
|
||||
# Firstname - None
|
||||
# Lastname - None
|
||||
# Email - None
|
||||
# Anything Else Radio - Yes
|
||||
# Anything Else Text - None
|
||||
# NOTE: We should never have an instance where only firstname or only lastname are populated (they are both required)
|
||||
# However, if this happens, the application will default to False for has_cisa_representative
|
||||
{
|
||||
"has_cisa_representative": True,
|
||||
# Above will be overridden to False if cisa_rep_email is None bc of sync_yes_no_form_fields
|
||||
# Above will be overridden to False if cisa_representative_first_name is None or
|
||||
# cisa_representative_last_name is None bc of sync_yes_no_form_fields
|
||||
"cisa_representative_first_name": None,
|
||||
"cisa_representative_last_name": None,
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": True,
|
||||
"anything_else": None,
|
||||
"expected": True,
|
||||
},
|
||||
# CISA Rep - Yes
|
||||
# Firstname - None
|
||||
# Lastname - None
|
||||
# Email - None
|
||||
# Anything Else Radio - Yes
|
||||
# Anything Else Text - Yes
|
||||
{
|
||||
"has_cisa_representative": True,
|
||||
# Above will be overridden to False if cisa_rep_email is None bc of sync_yes_no_form_fields
|
||||
# Above will be overridden to False if cisa_representative_first_name is None or
|
||||
# cisa_representative_last_name is None bc of sync_yes_no_form_fields
|
||||
"cisa_representative_first_name": None,
|
||||
"cisa_representative_last_name": None,
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": True,
|
||||
"anything_else": "Some text",
|
||||
|
@ -1897,6 +1933,8 @@ class TestDomainRequestIncomplete(TestCase):
|
|||
# Anything Else Text - Yes
|
||||
{
|
||||
"has_cisa_representative": False,
|
||||
"cisa_representative_first_name": None,
|
||||
"cisa_representative_last_name": None,
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": True,
|
||||
"anything_else": "Some text",
|
||||
|
@ -1907,6 +1945,8 @@ class TestDomainRequestIncomplete(TestCase):
|
|||
# Anything Else Text - None
|
||||
{
|
||||
"has_cisa_representative": False,
|
||||
"cisa_representative_first_name": None,
|
||||
"cisa_representative_last_name": None,
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": True,
|
||||
"anything_else": None,
|
||||
|
@ -1917,6 +1957,8 @@ class TestDomainRequestIncomplete(TestCase):
|
|||
# Anything Else Text - None
|
||||
{
|
||||
"has_cisa_representative": False,
|
||||
"cisa_representative_first_name": None,
|
||||
"cisa_representative_last_name": None,
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": None,
|
||||
"anything_else": None,
|
||||
|
@ -1928,6 +1970,8 @@ class TestDomainRequestIncomplete(TestCase):
|
|||
# Anything Else Text - No
|
||||
{
|
||||
"has_cisa_representative": False,
|
||||
"cisa_representative_first_name": None,
|
||||
"cisa_representative_last_name": None,
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": False,
|
||||
"anything_else": None,
|
||||
|
@ -1937,6 +1981,8 @@ class TestDomainRequestIncomplete(TestCase):
|
|||
# Anything Else Radio - None
|
||||
{
|
||||
"has_cisa_representative": None,
|
||||
"cisa_representative_first_name": None,
|
||||
"cisa_representative_last_name": None,
|
||||
"cisa_representative_email": None,
|
||||
"has_anything_else_text": None,
|
||||
"anything_else": None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue