mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-31 15:06:32 +02:00
fixing tests
This commit is contained in:
parent
463632baf7
commit
96618ee2bc
2 changed files with 23 additions and 10 deletions
|
@ -95,7 +95,6 @@ class RequestingEntityForm(RegistrarForm):
|
|||
def clean_sub_organization(self):
|
||||
"""On suborganization clean, set the suborganization value to None if the user is requesting
|
||||
a custom suborganization (as it doesn't exist yet)"""
|
||||
|
||||
# If it's a new suborganization, return None (equivalent to selecting nothing)
|
||||
if self.cleaned_data.get("is_requesting_new_suborganization"):
|
||||
return None
|
||||
|
@ -129,7 +128,6 @@ class RequestingEntityForm(RegistrarForm):
|
|||
# Retrieve sub_organization and store in _original_suborganization
|
||||
suborganization = data.get("portfolio_requesting_entity-sub_organization")
|
||||
self._original_suborganization = suborganization
|
||||
|
||||
# If the original value was "other", clear it for validation
|
||||
if self._original_suborganization == "other":
|
||||
data["portfolio_requesting_entity-sub_organization"] = ""
|
||||
|
@ -171,7 +169,6 @@ class RequestingEntityForm(RegistrarForm):
|
|||
requesting_entity_is_suborganization = self.data.get(
|
||||
"portfolio_requesting_entity-requesting_entity_is_suborganization"
|
||||
)
|
||||
|
||||
if requesting_entity_is_suborganization == "True":
|
||||
if is_requesting_new_suborganization:
|
||||
if not cleaned_data.get("requested_suborganization") and "requested_suborganization" not in self.errors:
|
||||
|
|
|
@ -2879,7 +2879,7 @@ class TestRequestingEntity(WebTest):
|
|||
|
||||
form["portfolio_requesting_entity-requesting_entity_is_suborganization"] = True
|
||||
form["portfolio_requesting_entity-is_requesting_new_suborganization"] = True
|
||||
form["portfolio_requesting_entity-sub_organization"] = ""
|
||||
form["portfolio_requesting_entity-sub_organization"] = "other"
|
||||
|
||||
form["portfolio_requesting_entity-requested_suborganization"] = "moon"
|
||||
form["portfolio_requesting_entity-suborganization_city"] = "kepler"
|
||||
|
@ -2933,7 +2933,7 @@ class TestRequestingEntity(WebTest):
|
|||
|
||||
@override_flag("organization_feature", active=True)
|
||||
@override_flag("organization_requests", active=True)
|
||||
@less_console_noise_decorator
|
||||
# @less_console_noise_decorator
|
||||
def test_requesting_entity_page_errors(self):
|
||||
"""Tests that we get the expected form errors on requesting entity"""
|
||||
domain_request = completed_domain_request(user=self.user, portfolio=self.portfolio)
|
||||
|
@ -2942,18 +2942,34 @@ class TestRequestingEntity(WebTest):
|
|||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||
|
||||
# For 2 the tests below, it is required to submit a form without submitting a value
|
||||
# for the select/combobox. WebTest will not do this; by default, WebTest will submit
|
||||
# the first choice in a select. So, need to manipulate the form to remove the
|
||||
# particular select/combobox that will not be submitted, and then post the form.
|
||||
form_action = f"/request/{domain_request.pk}/portfolio_requesting_entity/"
|
||||
|
||||
# Test missing suborganization selection
|
||||
form["portfolio_requesting_entity-requesting_entity_is_suborganization"] = True
|
||||
form["portfolio_requesting_entity-sub_organization"] = ""
|
||||
|
||||
response = form.submit()
|
||||
form["portfolio_requesting_entity-is_requesting_new_suborganization"] = False
|
||||
# remove sub_organization from the form submission
|
||||
form_data = form.submit_fields()
|
||||
form_data = [(key, value) for key, value in form_data if key != "portfolio_requesting_entity-sub_organization"]
|
||||
response = self.app.post(form_action, dict(form_data))
|
||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||
self.assertContains(response, "Suborganization is required.", status_code=200)
|
||||
|
||||
# Test missing custom suborganization details
|
||||
form["portfolio_requesting_entity-requesting_entity_is_suborganization"] = True
|
||||
form["portfolio_requesting_entity-is_requesting_new_suborganization"] = True
|
||||
response = form.submit()
|
||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||
form["portfolio_requesting_entity-sub_organization"] = "other"
|
||||
# remove suborganization_state_territory from the form submission
|
||||
form_data = form.submit_fields()
|
||||
form_data = [
|
||||
(key, value)
|
||||
for key, value in form_data
|
||||
if key != "portfolio_requesting_entity-suborganization_state_territory"
|
||||
]
|
||||
response = self.app.post(form_action, dict(form_data))
|
||||
self.assertContains(response, "Enter the name of your suborganization.", status_code=200)
|
||||
self.assertContains(response, "Enter the city where your suborganization is located.", status_code=200)
|
||||
self.assertContains(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue