mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-15 14:04:10 +02:00
formatted for code readability
This commit is contained in:
parent
ce89649c7b
commit
7a666c536f
3 changed files with 25 additions and 19 deletions
|
@ -44,12 +44,12 @@ class CheckUserProfileMiddleware:
|
||||||
self.regular_excluded_pages = [
|
self.regular_excluded_pages = [
|
||||||
self.setup_page,
|
self.setup_page,
|
||||||
self.logout_page,
|
self.logout_page,
|
||||||
'/admin',
|
"/admin",
|
||||||
]
|
]
|
||||||
self.other_excluded_pages = [
|
self.other_excluded_pages = [
|
||||||
self.profile_page,
|
self.profile_page,
|
||||||
self.logout_page,
|
self.logout_page,
|
||||||
'/admin',
|
"/admin",
|
||||||
]
|
]
|
||||||
|
|
||||||
def __call__(self, request):
|
def __call__(self, request):
|
||||||
|
@ -112,8 +112,7 @@ class CheckUserProfileMiddleware:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _handle_other_user_setup_not_finished(self, request):
|
def _handle_other_user_setup_not_finished(self, request):
|
||||||
"""Redirects the given user to the profile page to finish setup.
|
"""Redirects the given user to the profile page to finish setup."""
|
||||||
"""
|
|
||||||
|
|
||||||
# Don't redirect on excluded pages (such as the setup page itself)
|
# Don't redirect on excluded pages (such as the setup page itself)
|
||||||
if not any(request.path.startswith(page) for page in self.other_excluded_pages):
|
if not any(request.path.startswith(page) for page in self.other_excluded_pages):
|
||||||
|
|
|
@ -69,11 +69,18 @@ class TestWithUser(MockEppLib):
|
||||||
email_2 = "unicorn@igorville.com"
|
email_2 = "unicorn@igorville.com"
|
||||||
# in the case below, REGULAR user is 'Verified by Login.gov, ie. IAL2
|
# in the case below, REGULAR user is 'Verified by Login.gov, ie. IAL2
|
||||||
self.incomplete_regular_user = get_user_model().objects.create(
|
self.incomplete_regular_user = get_user_model().objects.create(
|
||||||
username=username_regular_incomplete, first_name=first_name_2, email=email_2, verification_type=User.VerificationTypeChoices.REGULAR
|
username=username_regular_incomplete,
|
||||||
|
first_name=first_name_2,
|
||||||
|
email=email_2,
|
||||||
|
verification_type=User.VerificationTypeChoices.REGULAR,
|
||||||
)
|
)
|
||||||
# in the case below, other user is representative of GRANDFATHERED, VERIFIED_BY_STAFF, INVITED, FIXTURE_USER, ie. IAL1
|
# in the case below, other user is representative of GRANDFATHERED,
|
||||||
|
# VERIFIED_BY_STAFF, INVITED, FIXTURE_USER, ie. IAL1
|
||||||
self.incomplete_other_user = get_user_model().objects.create(
|
self.incomplete_other_user = get_user_model().objects.create(
|
||||||
username=username_other_incomplete, first_name=first_name_2, email=email_2, verification_type=User.VerificationTypeChoices.VERIFIED_BY_STAFF
|
username=username_other_incomplete,
|
||||||
|
first_name=first_name_2,
|
||||||
|
email=email_2,
|
||||||
|
verification_type=User.VerificationTypeChoices.VERIFIED_BY_STAFF,
|
||||||
)
|
)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
@ -679,24 +686,23 @@ class FinishUserProfileForOtherUsersTests(TestWithUser, WebTest):
|
||||||
# Assert that modal does not appear on subsequent submits
|
# Assert that modal does not appear on subsequent submits
|
||||||
self.assertNotContains(user_profile_page, "domain registrants must maintain accurate contact information")
|
self.assertNotContains(user_profile_page, "domain registrants must maintain accurate contact information")
|
||||||
# Assert that unique error message appears by testing the message in a specific div
|
# Assert that unique error message appears by testing the message in a specific div
|
||||||
html_content = user_profile_page.content.decode('utf-8')
|
html_content = user_profile_page.content.decode("utf-8")
|
||||||
# Normalize spaces and line breaks in the HTML content
|
# Normalize spaces and line breaks in the HTML content
|
||||||
normalized_html_content = ' '.join(html_content.split())
|
normalized_html_content = " ".join(html_content.split())
|
||||||
# Expected string without extra spaces and line breaks
|
# Expected string without extra spaces and line breaks
|
||||||
expected_string = 'Before you can manage your domain, we need you to add contact information.'
|
expected_string = "Before you can manage your domain, we need you to add contact information."
|
||||||
# Check for the presence of the <div> element with the specific text
|
# Check for the presence of the <div> element with the specific text
|
||||||
self.assertIn(f'<div class="usa-alert__body"> {expected_string} </div>', normalized_html_content)
|
self.assertIn(f'<div class="usa-alert__body"> {expected_string} </div>', normalized_html_content)
|
||||||
|
|
||||||
|
|
||||||
#self.assertContains(user_profile_page, "Before you can manage your domain, we need you to add contact information.")
|
|
||||||
|
|
||||||
# We're missing a phone number, so the page should tell us that
|
# We're missing a phone number, so the page should tell us that
|
||||||
self.assertContains(user_profile_page, "Enter your phone number.")
|
self.assertContains(user_profile_page, "Enter your phone number.")
|
||||||
|
|
||||||
# We need to assert that links to manage your domain are not present (in both body and footer)
|
# We need to assert that links to manage your domain are not present (in both body and footer)
|
||||||
self.assertNotContains(user_profile_page, "Manage your domains")
|
self.assertNotContains(user_profile_page, "Manage your domains")
|
||||||
# Assert the tooltip on the logo, indicating that the logo is not clickable
|
# Assert the tooltip on the logo, indicating that the logo is not clickable
|
||||||
self.assertContains(user_profile_page, 'title="Before you can manage your domains, we need you to add contact information."')
|
self.assertContains(
|
||||||
|
user_profile_page, 'title="Before you can manage your domains, we need you to add contact information."'
|
||||||
|
)
|
||||||
# Assert that modal does not appear on subsequent submits
|
# Assert that modal does not appear on subsequent submits
|
||||||
self.assertNotContains(user_profile_page, "domain registrants must maintain accurate contact information")
|
self.assertNotContains(user_profile_page, "domain registrants must maintain accurate contact information")
|
||||||
|
|
||||||
|
@ -712,7 +718,9 @@ class FinishUserProfileForOtherUsersTests(TestWithUser, WebTest):
|
||||||
|
|
||||||
# We need to assert that logo is not clickable and links to manage your domain are not present
|
# We need to assert that logo is not clickable and links to manage your domain are not present
|
||||||
self.assertContains(save_page, "anage your domains", count=2)
|
self.assertContains(save_page, "anage your domains", count=2)
|
||||||
self.assertNotContains(save_page, "Before you can manage your domains, we need you to add contact information")
|
self.assertNotContains(
|
||||||
|
save_page, "Before you can manage your domains, we need you to add contact information"
|
||||||
|
)
|
||||||
# Assert that modal does not appear on subsequent submits
|
# Assert that modal does not appear on subsequent submits
|
||||||
self.assertNotContains(save_page, "domain registrants must maintain accurate contact information")
|
self.assertNotContains(save_page, "domain registrants must maintain accurate contact information")
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,6 @@ class UserProfileView(UserProfilePermissionView, FormMixin):
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
"""Redirect to the user's profile page."""
|
"""Redirect to the user's profile page."""
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue