mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 01:57:03 +02:00
Linting and fix existing unit test
This commit is contained in:
parent
2863e29d96
commit
4be1e3e29e
5 changed files with 11 additions and 42 deletions
|
@ -22,7 +22,7 @@ from epplibwrapper.errors import ErrorCode, RegistryError
|
|||
from registrar.models.user_domain_role import UserDomainRole
|
||||
from waffle.admin import FlagAdmin
|
||||
from waffle.models import Sample, Switch
|
||||
from registrar.models import Contact, Domain, DomainRequest, DraftDomain, User, Website, SeniorOfficial
|
||||
from registrar.models import Contact, Domain, DomainRequest, DraftDomain, User, Website
|
||||
from registrar.utility.errors import FSMDomainRequestError, FSMErrorCodes
|
||||
from registrar.views.utility.mixins import OrderableFieldsMixin
|
||||
from django.contrib.admin.views.main import ORDER_VAR
|
||||
|
|
|
@ -322,6 +322,7 @@ class SeniorOfficialContactForm(ContactForm):
|
|||
|
||||
JOIN = "senior_official"
|
||||
full_name = forms.CharField(label="Full name", required=False)
|
||||
|
||||
def __init__(self, disable_fields=False, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
|
|
@ -77,6 +77,7 @@ class PortfolioSeniorOfficialForm(forms.ModelForm):
|
|||
|
||||
JOIN = "senior_official"
|
||||
full_name = forms.CharField(label="Full name", required=False)
|
||||
|
||||
class Meta:
|
||||
model = SeniorOfficial
|
||||
fields = [
|
||||
|
|
|
@ -1192,14 +1192,14 @@ class TestDomainSeniorOfficial(TestDomainOverview):
|
|||
self.assertTrue("disabled" in form[field_name].attrs)
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_domain_edit_senior_official_federal(self):
|
||||
def test_domain_cannot_edit_senior_official_when_federal(self):
|
||||
"""Tests that no edit can occur when the underlying domain is federal"""
|
||||
|
||||
# Set the org type to federal
|
||||
self.domain_information.generic_org_type = DomainInformation.OrganizationChoices.FEDERAL
|
||||
self.domain_information.save()
|
||||
|
||||
# Add an SO. We can do this at the model level, just not the form level.
|
||||
# Add an SO
|
||||
self.domain_information.senior_official = Contact(
|
||||
first_name="Apple", last_name="Tester", title="CIO", email="nobody@igorville.gov"
|
||||
)
|
||||
|
@ -1210,43 +1210,10 @@ class TestDomainSeniorOfficial(TestDomainOverview):
|
|||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||
|
||||
# Test if the form is populating data correctly
|
||||
so_form = so_page.forms[0]
|
||||
|
||||
test_cases = [
|
||||
("first_name", "Apple"),
|
||||
("last_name", "Tester"),
|
||||
("title", "CIO"),
|
||||
("email", "nobody@igorville.gov"),
|
||||
]
|
||||
self.assert_all_form_fields_have_expected_values(so_form, test_cases, test_for_disabled=True)
|
||||
|
||||
# Attempt to change data on each field. Because this domain is federal,
|
||||
# this should not succeed.
|
||||
so_form["first_name"] = "Orange"
|
||||
so_form["last_name"] = "Smoothie"
|
||||
so_form["title"] = "Cat"
|
||||
so_form["email"] = "somebody@igorville.gov"
|
||||
|
||||
submission = so_form.submit()
|
||||
|
||||
# A 302 indicates this page underwent a redirect.
|
||||
self.assertEqual(submission.status_code, 302)
|
||||
|
||||
followed_submission = submission.follow()
|
||||
|
||||
# Test the returned form for data accuracy. These values should be unchanged.
|
||||
new_form = followed_submission.forms[0]
|
||||
self.assert_all_form_fields_have_expected_values(new_form, test_cases, test_for_disabled=True)
|
||||
|
||||
# refresh domain information. Test these values in the DB.
|
||||
self.domain_information.refresh_from_db()
|
||||
|
||||
# All values should be unchanged. These are defined manually for code clarity.
|
||||
self.assertEqual("Apple", self.domain_information.senior_official.first_name)
|
||||
self.assertEqual("Tester", self.domain_information.senior_official.last_name)
|
||||
self.assertEqual("CIO", self.domain_information.senior_official.title)
|
||||
self.assertEqual("nobody@igorville.gov", self.domain_information.senior_official.email)
|
||||
self.assertContains(so_page, "Apple Tester")
|
||||
self.assertContains(so_page, "CIO")
|
||||
self.assertContains(so_page, "nobody@igorville.gov")
|
||||
self.assertNotContains(so_page, "Save")
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_domain_edit_senior_official_tribal(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue