This commit is contained in:
Rachid Mrad 2024-02-01 18:28:00 -05:00
parent 1130b5db8e
commit 4335271656
No known key found for this signature in database
2 changed files with 31 additions and 32 deletions

View file

@ -6,8 +6,6 @@ from django.test import Client, TestCase
from django.urls import reverse
from django.contrib.auth import get_user_model
from django.contrib.sessions.models import Session
from .common import MockEppLib, MockSESClient, completed_application, create_user # type: ignore
from django_webtest import WebTest # type: ignore
import boto3_mocking # type: ignore
@ -2390,21 +2388,21 @@ class TestWizardUnlockingSteps(TestWithUser, WebTest):
"""Test when all fields in the application are empty."""
unlocked_steps = self.wizard.db_check_for_unlocking_steps()
expected_dict = {
'about_your_organization': False,
'anything_else': False,
'authorizing_official': False,
'current_sites': False,
'dotgov_domain': False,
'organization_contact': False,
'organization_election': False,
'organization_federal': False,
'organization_type': False,
'other_contacts': False,
'purpose': False,
'requirements': False,
'review': False,
'tribal_government': False,
'your_contact': False
"about_your_organization": False,
"anything_else": False,
"authorizing_official": False,
"current_sites": False,
"dotgov_domain": False,
"organization_contact": False,
"organization_election": False,
"organization_federal": False,
"organization_type": False,
"other_contacts": False,
"purpose": False,
"requirements": False,
"review": False,
"tribal_government": False,
"your_contact": False,
}
self.assertEqual(unlocked_steps, expected_dict)
@ -2435,9 +2433,9 @@ class TestWizardUnlockingSteps(TestWithUser, WebTest):
detail_page = response.follow()
self.wizard.get_context_data()
except:
except Exception as err:
# Handle any potential errors while following the redirect
self.fail("Error following the redirect")
self.fail(f"Error following the redirect {err}")
# Now 'detail_page' contains the response after following the redirect
self.assertEqual(detail_page.status_code, 200)
@ -2501,15 +2499,15 @@ class TestWizardUnlockingSteps(TestWithUser, WebTest):
detail_page = response.follow()
self.wizard.get_context_data()
except:
except Exception as err:
# Handle any potential errors while following the redirect
self.fail("Error following the redirect")
self.fail(f"Error following the redirect {err}")
# Now 'detail_page' contains the response after following the redirect
self.assertEqual(detail_page.status_code, 200)
# 5 unlocked steps (ao, domain, submitter, other contacts, and current sites which unlocks if domain exists),
# one active step, the review step is locked
# 5 unlocked steps (ao, domain, submitter, other contacts, and current sites
# which unlocks if domain exists), one active step, the review step is locked
self.assertContains(detail_page, "#check_circle", count=5)
# Type of organization
self.assertContains(detail_page, "usa-current", count=1)

View file

@ -333,10 +333,10 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView):
DomainApplication.ApplicationStatus.ACTION_NEEDED,
]
return DomainApplication.objects.filter(creator=self.request.user, status__in=check_statuses)
def db_check_for_unlocking_steps(self):
"""Helper for get_context_data
Queries the DB for an application and returns a dict for unlocked steps."""
return {
"organization_type": bool(self.application.organization_type),
@ -344,10 +344,13 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView):
"organization_federal": bool(self.application.federal_type),
"organization_election": bool(self.application.is_election_board),
"organization_contact": (
bool(self.application.federal_agency) or bool(self.application.organization_name) or
bool(self.application.address_line1) or bool(self.application.city) or
bool(self.application.state_territory) or bool(self.application.zipcode) or
bool(self.application.urbanization)
bool(self.application.federal_agency)
or bool(self.application.organization_name)
or bool(self.application.address_line1)
or bool(self.application.city)
or bool(self.application.state_territory)
or bool(self.application.zipcode)
or bool(self.application.urbanization)
),
"about_your_organization": bool(self.application.about_your_organization),
"authorizing_official": bool(self.application.authorizing_official),
@ -360,9 +363,7 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView):
"other_contacts": (
bool(self.application.other_contacts.exists()) or bool(self.application.no_other_contacts_rationale)
),
"anything_else": (
bool(self.application.anything_else) or bool(self.application.is_policy_acknowledged)
),
"anything_else": (bool(self.application.anything_else) or bool(self.application.is_policy_acknowledged)),
"requirements": bool(self.application.is_policy_acknowledged),
"review": bool(self.application.is_policy_acknowledged),
}