mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-06-11 06:54:48 +02:00
Mr/error messages (#369)
* Make error messages match google doc. * Update application_wizard.py * Update application_wizard.py * Update application_wizard.py * Update application_wizard.py * Update application_wizard.py * Update application_wizard.py * Update application_wizard.py * Fix tests and re-format source code * Update application_wizard.py * Re-format code to make tests pass Co-authored-by: Neil MartinsenBurrell <neil.martinsen-burrell@gsa.gov>
This commit is contained in:
parent
508e5384cb
commit
76d2810a8a
2 changed files with 182 additions and 46 deletions
|
@ -62,7 +62,7 @@ class OrganizationTypeForm(RegistrarForm):
|
||||||
required=True,
|
required=True,
|
||||||
choices=DomainApplication.OrganizationChoices.choices,
|
choices=DomainApplication.OrganizationChoices.choices,
|
||||||
widget=forms.RadioSelect,
|
widget=forms.RadioSelect,
|
||||||
error_messages={"required": "This question is required."},
|
error_messages={"required": "Select the type of organization you represent."},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,7 +70,11 @@ class OrganizationFederalForm(RegistrarForm):
|
||||||
federal_type = forms.ChoiceField(
|
federal_type = forms.ChoiceField(
|
||||||
choices=DomainApplication.BranchChoices.choices,
|
choices=DomainApplication.BranchChoices.choices,
|
||||||
widget=forms.RadioSelect,
|
widget=forms.RadioSelect,
|
||||||
error_messages={"required": "This question is required."},
|
error_messages={
|
||||||
|
"required": (
|
||||||
|
"Select the part of the federal government your organization is in."
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,7 +95,8 @@ class OrganizationElectionForm(RegistrarForm):
|
||||||
is_election_board = self.cleaned_data["is_election_board"]
|
is_election_board = self.cleaned_data["is_election_board"]
|
||||||
if is_election_board is None:
|
if is_election_board is None:
|
||||||
raise forms.ValidationError(
|
raise forms.ValidationError(
|
||||||
"Please select Yes or No.",
|
"Select “Yes” if you represent an election office. Select “No” if you"
|
||||||
|
" don’t.",
|
||||||
code="required",
|
code="required",
|
||||||
)
|
)
|
||||||
return is_election_board
|
return is_election_board
|
||||||
|
@ -109,29 +114,48 @@ class OrganizationContactForm(RegistrarForm):
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
)
|
)
|
||||||
organization_name = forms.CharField(
|
organization_name = forms.CharField(
|
||||||
label="Organization Name", label_suffix=REQUIRED_SUFFIX
|
label="Organization name",
|
||||||
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
|
required=True,
|
||||||
|
error_messages={"required": "Enter the name of your organization."},
|
||||||
)
|
)
|
||||||
address_line1 = forms.CharField(
|
address_line1 = forms.CharField(
|
||||||
label="Street address",
|
label="Street address",
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
|
required=True,
|
||||||
|
error_messages={"required": "Enter the street address of your organization."},
|
||||||
)
|
)
|
||||||
address_line2 = forms.CharField(
|
address_line2 = forms.CharField(
|
||||||
required=False,
|
required=False,
|
||||||
label="Street address line 2",
|
label="Street address line 2",
|
||||||
)
|
)
|
||||||
city = forms.CharField(label="City", label_suffix=REQUIRED_SUFFIX)
|
city = forms.CharField(
|
||||||
|
label="City",
|
||||||
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
|
required=True,
|
||||||
|
error_messages={
|
||||||
|
"required": "Enter the city where your organization is located."
|
||||||
|
},
|
||||||
|
)
|
||||||
state_territory = forms.ChoiceField(
|
state_territory = forms.ChoiceField(
|
||||||
label="State, territory, or military post",
|
label="State, territory, or military post",
|
||||||
choices=[("", "--Select--")] + DomainApplication.StateTerritoryChoices.choices,
|
choices=[("", "--Select--")] + DomainApplication.StateTerritoryChoices.choices,
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
|
required=True,
|
||||||
|
error_messages={
|
||||||
|
"required": (
|
||||||
|
"Select the state, territory, or military post where your organization"
|
||||||
|
" is located."
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
zipcode = forms.CharField(
|
zipcode = forms.CharField(
|
||||||
label="ZIP code",
|
label="Zip code",
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
validators=[
|
validators=[
|
||||||
RegexValidator(
|
RegexValidator(
|
||||||
"^[0-9]{5}(?:-[0-9]{4})?$|^$",
|
"^[0-9]{5}(?:-[0-9]{4})?$|^$",
|
||||||
message="Please enter a ZIP code in the form 12345 or 12345-6789",
|
message="Enter a zip code in the form of 12345 or 12345-6789.",
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -149,13 +173,15 @@ class OrganizationContactForm(RegistrarForm):
|
||||||
if not federal_agency:
|
if not federal_agency:
|
||||||
# no answer was selected
|
# no answer was selected
|
||||||
raise forms.ValidationError(
|
raise forms.ValidationError(
|
||||||
"Please select your federal agency.", code="required"
|
"Select the federal agency your organization is in.",
|
||||||
|
code="required",
|
||||||
)
|
)
|
||||||
if self.application.is_federal():
|
if self.application.is_federal():
|
||||||
if not federal_agency:
|
if not federal_agency:
|
||||||
# no answer was selected
|
# no answer was selected
|
||||||
raise forms.ValidationError(
|
raise forms.ValidationError(
|
||||||
"Please select your federal agency.", code="required"
|
"Select the federal agency your organization is in.",
|
||||||
|
code="required",
|
||||||
)
|
)
|
||||||
return federal_agency
|
return federal_agency
|
||||||
|
|
||||||
|
@ -166,15 +192,24 @@ class TypeOfWorkForm(RegistrarForm):
|
||||||
label="What type of work does your organization do? ",
|
label="What type of work does your organization do? ",
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
widget=forms.Textarea(),
|
widget=forms.Textarea(),
|
||||||
|
error_messages={"required": "Enter the type of work your organization does."},
|
||||||
)
|
)
|
||||||
|
|
||||||
more_organization_information = forms.CharField(
|
more_organization_information = forms.CharField(
|
||||||
# label has to end in a space to get the label_suffix to show
|
# label has to end in a space to get the label_suffix to show
|
||||||
label="Describe how your organization is a government organization that is "
|
label=(
|
||||||
"independent of a state government. Include links to authorizing legislation, "
|
"Describe how your organization is a government organization that is"
|
||||||
"applicable bylaws or charter, or other documentation to support your claims. ",
|
" independent of a state government. Include links to authorizing"
|
||||||
|
" legislation, applicable bylaws or charter, or other documentation to"
|
||||||
|
" support your claims. "
|
||||||
|
),
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
widget=forms.Textarea(),
|
widget=forms.Textarea(),
|
||||||
|
error_messages={
|
||||||
|
"required": (
|
||||||
|
"Describe how your organization is independent of a state government."
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -197,29 +232,56 @@ class AuthorizingOfficialForm(RegistrarForm):
|
||||||
return super().from_database(contact)
|
return super().from_database(contact)
|
||||||
|
|
||||||
first_name = forms.CharField(
|
first_name = forms.CharField(
|
||||||
label="First name/given name",
|
label="First name / given name",
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
|
required=True,
|
||||||
|
error_messages={
|
||||||
|
"required": (
|
||||||
|
"Enter the first name / given name of your authorizing official."
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
middle_name = forms.CharField(
|
middle_name = forms.CharField(
|
||||||
required=False,
|
required=False,
|
||||||
label="Middle name",
|
label="Middle name",
|
||||||
)
|
)
|
||||||
last_name = forms.CharField(
|
last_name = forms.CharField(
|
||||||
label="Last name/family name",
|
label="Last name / family name",
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
|
required=True,
|
||||||
|
error_messages={
|
||||||
|
"required": (
|
||||||
|
"Enter the last name / family name of your authorizing official."
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
title = forms.CharField(
|
title = forms.CharField(
|
||||||
label="Title or role in your organization",
|
label="Title or role in your organization",
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
|
required=True,
|
||||||
|
error_messages={
|
||||||
|
"required": (
|
||||||
|
"Enter the title or role your authorizing official has in your"
|
||||||
|
" organization (e.g., Chief Information Officer)."
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
email = forms.EmailField(
|
email = forms.EmailField(
|
||||||
label="Email",
|
label="Email",
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
error_messages={"invalid": "Please enter a valid email address."},
|
error_messages={
|
||||||
|
"invalid": (
|
||||||
|
"Enter an email address in the required format, like name@example.com."
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
phone = PhoneNumberField(
|
phone = PhoneNumberField(
|
||||||
label="Phone",
|
label="Phone",
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
|
required=True,
|
||||||
|
error_messages={
|
||||||
|
"required": "Enter the phone number for your authorizing official."
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -243,8 +305,10 @@ class CurrentSitesForm(RegistrarForm):
|
||||||
|
|
||||||
current_site = forms.CharField(
|
current_site = forms.CharField(
|
||||||
required=False,
|
required=False,
|
||||||
label="Enter your organization’s public website, if you have one. For example, "
|
label=(
|
||||||
"www.city.com.",
|
"Enter your organization’s website in the required format, like"
|
||||||
|
" www.city.com."
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
def clean_current_site(self):
|
def clean_current_site(self):
|
||||||
|
@ -265,7 +329,9 @@ class CurrentSitesForm(RegistrarForm):
|
||||||
else:
|
else:
|
||||||
# string could not be a domain
|
# string could not be a domain
|
||||||
raise forms.ValidationError(
|
raise forms.ValidationError(
|
||||||
"Please enter a valid domain name", code="invalid"
|
"Enter your organization’s website in the required format, like"
|
||||||
|
" www.city.com.",
|
||||||
|
code="invalid",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -312,8 +378,10 @@ class DotGovDomainForm(RegistrarForm):
|
||||||
)
|
)
|
||||||
alternative_domain = forms.CharField(
|
alternative_domain = forms.CharField(
|
||||||
required=False,
|
required=False,
|
||||||
label="Are there other domains you’d like if we can’t give you your first "
|
label=(
|
||||||
"choice? Entering alternative domains is optional.",
|
"Are there other domains you’d like if we can’t give you your first "
|
||||||
|
"choice? Entering alternative domains is optional."
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
def clean_requested_domain(self):
|
def clean_requested_domain(self):
|
||||||
|
@ -326,19 +394,22 @@ class DotGovDomainForm(RegistrarForm):
|
||||||
if not requested:
|
if not requested:
|
||||||
# none or empty string
|
# none or empty string
|
||||||
raise forms.ValidationError(
|
raise forms.ValidationError(
|
||||||
"Please enter the .gov domain that you are requesting.", code="invalid"
|
"Enter the .gov domain you want. Don’t include “www” or “.gov.” For"
|
||||||
|
" example, if you want www.city.gov, you would enter “city” (without"
|
||||||
|
" the quotes).",
|
||||||
|
code="invalid",
|
||||||
)
|
)
|
||||||
if requested.endswith(".gov"):
|
if requested.endswith(".gov"):
|
||||||
requested = requested[:-4]
|
requested = requested[:-4]
|
||||||
if "." in requested:
|
if "." in requested:
|
||||||
raise forms.ValidationError(
|
raise forms.ValidationError(
|
||||||
"Please enter a domain without any periods.",
|
"Enter the .gov domain you want without any periods.",
|
||||||
code="invalid",
|
code="invalid",
|
||||||
)
|
)
|
||||||
if not Domain.string_could_be_domain(requested + ".gov"):
|
if not Domain.string_could_be_domain(requested + ".gov"):
|
||||||
raise forms.ValidationError(
|
raise forms.ValidationError(
|
||||||
"Please enter a valid domain name using only letters, "
|
"Enter a domain using only letters, "
|
||||||
"numbers, and hyphens",
|
"numbers, or hyphens (though we don't recommend using hyphens).",
|
||||||
code="invalid",
|
code="invalid",
|
||||||
)
|
)
|
||||||
return requested
|
return requested
|
||||||
|
@ -349,7 +420,7 @@ class PurposeForm(RegistrarForm):
|
||||||
label="Purpose",
|
label="Purpose",
|
||||||
widget=forms.Textarea(),
|
widget=forms.Textarea(),
|
||||||
error_messages={
|
error_messages={
|
||||||
"required": "Please enter some information about the purpose of your domain"
|
"required": "Describe how you'll use the .gov domain you’re requesting."
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -373,29 +444,48 @@ class YourContactForm(RegistrarForm):
|
||||||
return super().from_database(contact)
|
return super().from_database(contact)
|
||||||
|
|
||||||
first_name = forms.CharField(
|
first_name = forms.CharField(
|
||||||
label="First name/given name",
|
label="First name / given name",
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
|
required=True,
|
||||||
|
error_messages={"required": "Enter your first name / given name."},
|
||||||
)
|
)
|
||||||
middle_name = forms.CharField(
|
middle_name = forms.CharField(
|
||||||
required=False,
|
required=False,
|
||||||
label="Middle name",
|
label="Middle name",
|
||||||
)
|
)
|
||||||
last_name = forms.CharField(
|
last_name = forms.CharField(
|
||||||
label="Last name/family name",
|
label="Last name / family name",
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
|
required=True,
|
||||||
|
error_messages={"required": "Enter your last name / family name."},
|
||||||
)
|
)
|
||||||
title = forms.CharField(
|
title = forms.CharField(
|
||||||
label="Title or role in your organization",
|
label="Title or role in your organization",
|
||||||
|
required=True,
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
|
error_messages={
|
||||||
|
"required": (
|
||||||
|
"Enter your title or role in your organization (e.g., Chief Information"
|
||||||
|
" Officer)."
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
email = forms.EmailField(
|
email = forms.EmailField(
|
||||||
label="Email",
|
label="Email",
|
||||||
|
required=True,
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
error_messages={"invalid": "Please enter a valid email address."},
|
error_messages={
|
||||||
|
"invalid": (
|
||||||
|
"Enter your email address in the required format, like"
|
||||||
|
" name@example.com."
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
phone = PhoneNumberField(
|
phone = PhoneNumberField(
|
||||||
label="Phone",
|
label="Phone",
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
|
required=True,
|
||||||
|
error_messages={"required": "Enter your phone number."},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -420,44 +510,69 @@ class OtherContactsForm(RegistrarForm):
|
||||||
return super().from_database(other_contacts)
|
return super().from_database(other_contacts)
|
||||||
|
|
||||||
first_name = forms.CharField(
|
first_name = forms.CharField(
|
||||||
label="First name/given name",
|
label="First name / given name",
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
|
required=True,
|
||||||
|
error_messages={
|
||||||
|
"required": "Enter the first name / given name of this contact."
|
||||||
|
},
|
||||||
)
|
)
|
||||||
middle_name = forms.CharField(
|
middle_name = forms.CharField(
|
||||||
required=False,
|
required=False,
|
||||||
label="Middle name",
|
label="Middle name",
|
||||||
)
|
)
|
||||||
last_name = forms.CharField(
|
last_name = forms.CharField(
|
||||||
label="Last name/family name",
|
label="Last name / family name",
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
|
required=True,
|
||||||
|
error_messages={
|
||||||
|
"required": "Enter the last name / family name of this contact."
|
||||||
|
},
|
||||||
)
|
)
|
||||||
title = forms.CharField(
|
title = forms.CharField(
|
||||||
label="Title or role in your organization",
|
label="Title or role in your organization",
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
|
required=True,
|
||||||
|
error_messages={
|
||||||
|
"required": (
|
||||||
|
"Enter the title or role in your organization of this contact (e.g.,"
|
||||||
|
" Chief Information Officer)."
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
email = forms.EmailField(
|
email = forms.EmailField(
|
||||||
label="Email",
|
label="Email",
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
error_messages={"invalid": "Please enter a valid email address."},
|
error_messages={
|
||||||
|
"invalid": (
|
||||||
|
"Enter an email address in the required format, like name@example.com."
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
phone = PhoneNumberField(
|
phone = PhoneNumberField(
|
||||||
label="Phone",
|
label="Phone",
|
||||||
label_suffix=REQUIRED_SUFFIX,
|
label_suffix=REQUIRED_SUFFIX,
|
||||||
|
required=True,
|
||||||
|
error_messages={"required": "Enter a phone number for this contact."},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SecurityEmailForm(RegistrarForm):
|
class SecurityEmailForm(RegistrarForm):
|
||||||
security_email = forms.EmailField(
|
security_email = forms.EmailField(
|
||||||
required=False,
|
required=False,
|
||||||
label="Security email",
|
label="Security email for public use",
|
||||||
error_messages={"invalid": "Please enter a valid email address."},
|
error_messages={
|
||||||
|
"invalid": (
|
||||||
|
"Enter an email address in the required format, like name@example.com."
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class AnythingElseForm(RegistrarForm):
|
class AnythingElseForm(RegistrarForm):
|
||||||
anything_else = forms.CharField(
|
anything_else = forms.CharField(
|
||||||
required=False,
|
required=False,
|
||||||
label="Anything else we should know",
|
label="Anything else we should know?",
|
||||||
widget=forms.Textarea(),
|
widget=forms.Textarea(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -477,7 +592,8 @@ class RequirementsForm(RegistrarForm):
|
||||||
is_acknowledged = self.cleaned_data["is_policy_acknowledged"]
|
is_acknowledged = self.cleaned_data["is_policy_acknowledged"]
|
||||||
if not is_acknowledged:
|
if not is_acknowledged:
|
||||||
raise forms.ValidationError(
|
raise forms.ValidationError(
|
||||||
"You must read and agree to the .gov domain requirements to proceed.",
|
"Check the box if you read and agree to the requirements for"
|
||||||
|
" registering and operating .gov domains.",
|
||||||
code="invalid",
|
code="invalid",
|
||||||
)
|
)
|
||||||
return is_acknowledged
|
return is_acknowledged
|
||||||
|
|
|
@ -19,7 +19,7 @@ class TestFormValidation(TestCase):
|
||||||
form = OrganizationContactForm(data={"zipcode": "nah"})
|
form = OrganizationContactForm(data={"zipcode": "nah"})
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
form.errors["zipcode"],
|
form.errors["zipcode"],
|
||||||
["Please enter a ZIP code in the form 12345 or 12345-6789"],
|
["Enter a zip code in the form of 12345 or 12345-6789."],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_org_contact_zip_valid(self):
|
def test_org_contact_zip_valid(self):
|
||||||
|
@ -30,7 +30,11 @@ class TestFormValidation(TestCase):
|
||||||
def test_current_site_invalid(self):
|
def test_current_site_invalid(self):
|
||||||
form = CurrentSitesForm(data={"current_site": "nah"})
|
form = CurrentSitesForm(data={"current_site": "nah"})
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
form.errors["current_site"], ["Please enter a valid domain name"]
|
form.errors["current_site"],
|
||||||
|
[
|
||||||
|
"Enter your organization’s website in the required format, like"
|
||||||
|
" www.city.com."
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_current_site_valid(self):
|
def test_current_site_valid(self):
|
||||||
|
@ -59,7 +63,7 @@ class TestFormValidation(TestCase):
|
||||||
form = DotGovDomainForm(data={"requested_domain": "top-level-agency.com"})
|
form = DotGovDomainForm(data={"requested_domain": "top-level-agency.com"})
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
form.errors["requested_domain"],
|
form.errors["requested_domain"],
|
||||||
["Please enter a domain without any periods."],
|
["Enter the .gov domain you want without any periods."],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_requested_domain_invalid_characters(self):
|
def test_requested_domain_invalid_characters(self):
|
||||||
|
@ -68,15 +72,18 @@ class TestFormValidation(TestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
form.errors["requested_domain"],
|
form.errors["requested_domain"],
|
||||||
[
|
[
|
||||||
"Please enter a valid domain name using only letters, "
|
"Enter a domain using only letters, numbers, or hyphens (though we"
|
||||||
"numbers, and hyphens"
|
" don't recommend using hyphens)."
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_authorizing_official_email_invalid(self):
|
def test_authorizing_official_email_invalid(self):
|
||||||
"""must be a valid email address."""
|
"""must be a valid email address."""
|
||||||
form = AuthorizingOfficialForm(data={"email": "boss@boss"})
|
form = AuthorizingOfficialForm(data={"email": "boss@boss"})
|
||||||
self.assertEqual(form.errors["email"], ["Please enter a valid email address."])
|
self.assertEqual(
|
||||||
|
form.errors["email"],
|
||||||
|
["Enter an email address in the required format, like name@example.com."],
|
||||||
|
)
|
||||||
|
|
||||||
def test_authorizing_official_phone_invalid(self):
|
def test_authorizing_official_phone_invalid(self):
|
||||||
"""Must be a valid phone number."""
|
"""Must be a valid phone number."""
|
||||||
|
@ -88,7 +95,10 @@ class TestFormValidation(TestCase):
|
||||||
def test_your_contact_email_invalid(self):
|
def test_your_contact_email_invalid(self):
|
||||||
"""must be a valid email address."""
|
"""must be a valid email address."""
|
||||||
form = YourContactForm(data={"email": "boss@boss"})
|
form = YourContactForm(data={"email": "boss@boss"})
|
||||||
self.assertEqual(form.errors["email"], ["Please enter a valid email address."])
|
self.assertEqual(
|
||||||
|
form.errors["email"],
|
||||||
|
["Enter your email address in the required format, like name@example.com."],
|
||||||
|
)
|
||||||
|
|
||||||
def test_your_contact_phone_invalid(self):
|
def test_your_contact_phone_invalid(self):
|
||||||
"""Must be a valid phone number."""
|
"""Must be a valid phone number."""
|
||||||
|
@ -100,7 +110,10 @@ class TestFormValidation(TestCase):
|
||||||
def test_other_contact_email_invalid(self):
|
def test_other_contact_email_invalid(self):
|
||||||
"""must be a valid email address."""
|
"""must be a valid email address."""
|
||||||
form = OtherContactsForm(data={"email": "boss@boss"})
|
form = OtherContactsForm(data={"email": "boss@boss"})
|
||||||
self.assertEqual(form.errors["email"], ["Please enter a valid email address."])
|
self.assertEqual(
|
||||||
|
form.errors["email"],
|
||||||
|
["Enter an email address in the required format, like name@example.com."],
|
||||||
|
)
|
||||||
|
|
||||||
def test_other_contact_phone_invalid(self):
|
def test_other_contact_phone_invalid(self):
|
||||||
"""Must be a valid phone number."""
|
"""Must be a valid phone number."""
|
||||||
|
@ -118,7 +131,8 @@ class TestFormValidation(TestCase):
|
||||||
"""Can leave the security_email field blank."""
|
"""Can leave the security_email field blank."""
|
||||||
form = SecurityEmailForm(data={"security_email": "boss@boss"})
|
form = SecurityEmailForm(data={"security_email": "boss@boss"})
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
form.errors["security_email"], ["Please enter a valid email address."]
|
form.errors["security_email"],
|
||||||
|
["Enter an email address in the required format, like name@example.com."],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_requirements_form_blank(self):
|
def test_requirements_form_blank(self):
|
||||||
|
@ -126,7 +140,10 @@ class TestFormValidation(TestCase):
|
||||||
form = RequirementsForm(data={})
|
form = RequirementsForm(data={})
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
form.errors["is_policy_acknowledged"],
|
form.errors["is_policy_acknowledged"],
|
||||||
["You must read and agree to the .gov domain requirements to proceed."],
|
[
|
||||||
|
"Check the box if you read and agree to the requirements for"
|
||||||
|
" registering and operating .gov domains."
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_requirements_form_unchecked(self):
|
def test_requirements_form_unchecked(self):
|
||||||
|
@ -134,5 +151,8 @@ class TestFormValidation(TestCase):
|
||||||
form = RequirementsForm(data={"is_policy_acknowledged": False})
|
form = RequirementsForm(data={"is_policy_acknowledged": False})
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
form.errors["is_policy_acknowledged"],
|
form.errors["is_policy_acknowledged"],
|
||||||
["You must read and agree to the .gov domain requirements to proceed."],
|
[
|
||||||
|
"Check the box if you read and agree to the requirements for"
|
||||||
|
" registering and operating .gov domains."
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue