Fix linting and tets

This commit is contained in:
Rebecca Hsieh 2023-09-06 16:40:57 -07:00
parent 696941aba7
commit 34a2f39fdf
No known key found for this signature in database
GPG key ID: 644527A2F375A379
8 changed files with 35 additions and 73 deletions

View file

@ -309,6 +309,7 @@ class OrganizationContactForm(RegistrarForm):
)
return federal_agency
class AboutYourOrganizationForm(RegistrarForm):
about_your_organization = forms.CharField(
label="About your organization",
@ -319,12 +320,14 @@ class AboutYourOrganizationForm(RegistrarForm):
message="Response must be less than 1000 characters.",
)
],
# TODO-446: Confirm if this error message wording is ok, prev was "Enter the type of work your organization does."
# TODO-446: Confirm if err msg wording is ok, previously
# TODO-446: "Enter the type of work your organization does."
error_messages={
"required": ("Enter information about your organization.")
"required": ("Enter the information about your organization.")
},
)
class AuthorizingOfficialForm(RegistrarForm):
def to_database(self, obj):
if not self.is_valid():

View file

@ -433,6 +433,7 @@ def create_user():
password=p,
)
def completed_application(
has_other_contacts=True,
has_current_website=True,

View file

@ -316,7 +316,6 @@ class TestDomainApplicationAdmin(TestCase):
readonly_fields = self.admin.get_readonly_fields(request, application)
# TODO-446: Add about_your_organization + remove type_of_work and more_organization_information
expected_fields = [
"id",
"created_at",
@ -338,8 +337,7 @@ class TestDomainApplicationAdmin(TestCase):
"state_territory",
"zipcode",
"urbanization",
"type_of_work",
"more_organization_information",
"about_your_organization",
"authorizing_official",
"approved_domain",
"requested_domain",
@ -361,11 +359,9 @@ class TestDomainApplicationAdmin(TestCase):
readonly_fields = self.admin.get_readonly_fields(request)
# TODO-446: Add about_your_organization + remove type_of_work and more_organization_information
expected_fields = [
"creator",
"type_of_work",
"more_organization_information",
"about_your_organization",
"address_line1",
"address_line2",
"zipcode",

View file

@ -125,29 +125,27 @@ class TestEmails(TestCase):
# spacing should be right between adjacent elements
self.assertRegex(body, r"city.gov\n\nPurpose of your domain:")
# TODO-446: Update type_of_work -> about_your_organization
@boto3_mocking.patching
def test_submission_confirmation_type_of_work_spacing(self):
"""Test line spacing with type of work."""
application = completed_application(has_type_of_work=True)
def test_submission_confirmation_about_your_organization_spacing(self):
"""Test line spacing with about your organization."""
application = completed_application(has_about_your_organization=True)
with boto3_mocking.clients.handler_for("sesv2", self.mock_client_class):
application.submit()
_, kwargs = self.mock_client.send_email.call_args
body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"]
self.assertIn("Type of work:", body)
self.assertIn("About your organization:", body)
# spacing should be right between adjacent elements
self.assertRegex(body, r"10002\n\nType of work:")
self.assertRegex(body, r"10002\n\nAbout your organization:")
# TODO-446: Update type_of_work -> about_your_organization
@boto3_mocking.patching
def test_submission_confirmation_no_type_of_work_spacing(self):
def test_submission_confirmation_no_about_your_organization_spacing(self):
"""Test line spacing without type of work."""
application = completed_application(has_type_of_work=False)
application = completed_application(has_about_your_organization=False)
with boto3_mocking.clients.handler_for("sesv2", self.mock_client_class):
application.submit()
_, kwargs = self.mock_client.send_email.call_args
body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"]
self.assertNotIn("Type of work:", body)
self.assertNotIn("About your organization:", body)
# spacing should be right between adjacent elements
self.assertRegex(body, r"10002\n\nAuthorizing official:")

View file

@ -13,7 +13,7 @@ from registrar.forms.application_wizard import (
TribalGovernmentForm,
PurposeForm,
AnythingElseForm,
TypeOfWorkForm,
AboutYourOrganizationForm,
)
from registrar.forms.domain import ContactForm
@ -118,8 +118,7 @@ class TestFormValidation(TestCase):
["Response must be less than 1000 characters."],
)
# TODO-446: Update type_of_work -> about_your_organization
def test_anything_else_form_type_of_work_character_count_invalid(self):
def test_anything_else_form_about_your_organization_character_count_invalid(self):
"""Response must be less than 1000 characters."""
form = AnythingElseForm(
data={
@ -148,45 +147,12 @@ class TestFormValidation(TestCase):
["Response must be less than 1000 characters."],
)
# TODO-446: Can remove bc don't have this textbox anymore
def test_anything_else_form_more_organization_information_character_count_invalid(
self,
):
"""Response must be less than 1000 characters."""
form = TypeOfWorkForm(
data={
"more_organization_information": "Bacon ipsum dolor amet fatback"
"shankle, drumstick doner chicken landjaeger turkey andouille."
"Buffalo biltong chuck pork chop tongue bresaola turkey. Doner"
"ground round strip steak, jowl tail chuck ribeye bacon"
"beef ribs swine filet ball tip pancetta strip steak sirloin"
"mignon ham spare ribs rump. Tail shank biltong beef ribs doner"
"buffalo swine bacon. Tongue cow picanha brisket bacon chuck"
"leberkas pork loin pork, drumstick capicola. Doner short loin"
"ground round fatback turducken chislic shoulder turducken"
"spare ribs, burgdoggen kielbasa kevin frankfurter ball tip"
"pancetta cupim. Turkey meatball andouille porchetta hamburger"
"pork chop corned beef. Brisket short ribs turducken, pork chop"
"chislic turkey ball pork chop leberkas rump, rump bacon, jowl"
"tip ham. Shankle salami tongue venison short ribs kielbasa"
"tri-tip ham hock swine hamburger. Flank meatball corned beef"
"cow sausage ball tip kielbasa ham hock. Ball tip cupim meatloaf"
"beef ribs rump jowl tenderloin swine sausage biltong"
"bacon rump tail boudin meatball boudin meatball boudin"
"strip steak pastrami."
}
)
self.assertEqual(
form.errors["more_organization_information"],
["Response must be less than 1000 characters."],
)
# TODO-446: Update type_of_work -> about_your_organization in data and assertEqual
def test_anything_else_form_character_count_invalid(self):
"""Response must be less than 1000 characters."""
form = TypeOfWorkForm(
form = AboutYourOrganizationForm(
data={
"type_of_work": "Bacon ipsum dolor amet fatback strip steak pastrami"
"about_your_organization":
"Bacon ipsum dolor amet fatback strip steak pastrami"
"shankle, drumstick doner chicken landjaeger turkey andouille."
"Buffalo biltong chuck pork chop tongue bresaola turkey. Doner"
"ground round strip steak, jowl tail chuck ribeye bacon"
@ -207,7 +173,7 @@ class TestFormValidation(TestCase):
}
)
self.assertEqual(
form.errors["type_of_work"],
form.errors["about_your_organization"],
["Response must be less than 1000 characters."],
)

View file

@ -663,11 +663,12 @@ class DomainApplicationTests(TestWithUser, WebTest):
# the post request should return a redirect to the type of work page
# if it was successful.
self.assertEqual(contact_result.status_code, 302)
self.assertEqual(contact_result["Location"], "/register/type_of_work/")
# TODO-446: self.assertEqual(contact_result["Location"], "/register/about_your_organization/")
self.assertEqual(
contact_result["Location"],
"/register/about_your_organization/"
)
# TODO-446: Update type_of_work -> about_your_organization
def test_application_type_of_work_special(self):
def test_application_about_your_organization_special(self):
"""Special districts have to answer an additional question."""
type_page = self.app.get(reverse("application:")).follow()
# django-webtest does not handle cookie-based sessions well because it keeps
@ -686,9 +687,7 @@ class DomainApplicationTests(TestWithUser, WebTest):
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
contact_page = type_result.follow()
self.assertContains(contact_page, self.TITLES[Step.TYPE_OF_WORK])
# TODO-446: self.assertContains(contact_page, self.TITLES[Step.ABOUT_YOUR_ORGANIZATION])
self.assertContains(contact_page, self.TITLES[Step.ABOUT_YOUR_ORGANIZATION])
def test_application_no_other_contacts(self):
"""Applicants with no other contacts have to give a reason."""
@ -708,8 +707,7 @@ class DomainApplicationTests(TestWithUser, WebTest):
actual_url_slug = no_contacts_page.request.path.split("/")[-2]
self.assertEqual(expected_url_slug, actual_url_slug)
# TODO-446: Update type_of_work -> about_your_organization
def test_application_type_of_work_interstate(self):
def test_application_about_your_organiztion_interstate(self):
"""Special districts have to answer an additional question."""
type_page = self.app.get(reverse("application:")).follow()
# django-webtest does not handle cookie-based sessions well because it keeps
@ -728,9 +726,7 @@ class DomainApplicationTests(TestWithUser, WebTest):
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
contact_page = type_result.follow()
self.assertContains(contact_page, self.TITLES[Step.TYPE_OF_WORK])
# TODO-446: self.assertContains(contact_page, self.TITLES[Step.ABOUT_YOUR_ORGANIZATION])
self.assertContains(contact_page, self.TITLES[Step.ABOUT_YOUR_ORGANIZATION])
def test_application_tribal_government(self):
"""Tribal organizations have to answer an additional question."""

View file

@ -100,7 +100,9 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView):
Step.ORGANIZATION_ELECTION: lambda w: w.from_model(
"show_organization_election", False
),
Step.ABOUT_YOUR_ORGANIZATION: lambda w: w.from_model("show_about_your_organization", False),
Step.ABOUT_YOUR_ORGANIZATION: lambda w: w.from_model(
"show_about_your_organization", False
),
Step.NO_OTHER_CONTACTS: lambda w: w.from_model(
"show_no_other_contacts_rationale", False
),