mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-15 17:17:02 +02:00
Cleanup
This commit is contained in:
parent
92609f0486
commit
c4d8c1a38d
3 changed files with 32 additions and 19 deletions
|
@ -13,6 +13,7 @@ from registrar.models.public_contact import PublicContact
|
||||||
from registrar.models.user import User
|
from registrar.models.user import User
|
||||||
from registrar.models.user_domain_role import UserDomainRole
|
from registrar.models.user_domain_role import UserDomainRole
|
||||||
from registrar.views.domain import DomainNameserversView
|
from registrar.views.domain import DomainNameserversView
|
||||||
|
from registrar.models import SeniorOfficial, Suborganization
|
||||||
|
|
||||||
from .common import MockEppLib, less_console_noise # type: ignore
|
from .common import MockEppLib, less_console_noise # type: ignore
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
@ -87,6 +88,14 @@ class TestWithUser(MockEppLib):
|
||||||
super().tearDown()
|
super().tearDown()
|
||||||
DomainRequest.objects.all().delete()
|
DomainRequest.objects.all().delete()
|
||||||
DomainInformation.objects.all().delete()
|
DomainInformation.objects.all().delete()
|
||||||
|
# For some reason, if this is done on the test directly,
|
||||||
|
# we get a django.db.models.deletion.ProtectedError on "User".
|
||||||
|
# In either event, it doesn't hurt to have these here given their
|
||||||
|
# relationship.
|
||||||
|
Suborganization.objects.all().delete()
|
||||||
|
Portfolio.objects.all().delete()
|
||||||
|
SeniorOfficial.objects.all().delete()
|
||||||
|
|
||||||
User.objects.all().delete()
|
User.objects.all().delete()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1099,37 +1099,41 @@ class TestDomainSeniorOfficial(TestDomainOverview):
|
||||||
page = self.app.get(reverse("domain-senior-official", kwargs={"pk": self.domain.id}))
|
page = self.app.get(reverse("domain-senior-official", kwargs={"pk": self.domain.id}))
|
||||||
self.assertContains(page, "Testy")
|
self.assertContains(page, "Testy")
|
||||||
|
|
||||||
@override_flag("profile_feature", active=True)
|
@override_flag("organization_feature", active=True)
|
||||||
def test_domain_senior_official_content_profile_feature(self):
|
def test_domain_senior_official_content_profile_feature(self):
|
||||||
"""A portfolios senior official appears on the page
|
"""A portfolios senior official appears on the page
|
||||||
when the profile_feature flag is on."""
|
when the organization_feature flag is on."""
|
||||||
|
|
||||||
|
# Add a SO to the domain information object
|
||||||
self.domain_information.senior_official = Contact(first_name="Testy")
|
self.domain_information.senior_official = Contact(first_name="Testy")
|
||||||
self.domain_information.senior_official.save()
|
self.domain_information.senior_official.save()
|
||||||
self.domain_information.save()
|
self.domain_information.save()
|
||||||
|
|
||||||
# The page should not contain the SO on domain information
|
|
||||||
page = self.app.get(reverse("domain-senior-official", kwargs={"pk": self.domain.id}))
|
|
||||||
self.assertNotContains(page, "Testy")
|
|
||||||
|
|
||||||
# Add a portfolio to the current domain
|
# Add a portfolio to the current domain
|
||||||
portfolio = Portfolio.objects.create(creator=self.user, organization_name="Ice Cream")
|
portfolio = Portfolio.objects.create(creator=self.user, organization_name="Ice Cream")
|
||||||
suborganization = Suborganization.objects.create(portfolio=portfolio, name="Vanilla")
|
Suborganization.objects.create(portfolio=portfolio, name="Vanilla")
|
||||||
self.domain_information.portfolio = portfolio
|
self.domain_information.portfolio = portfolio
|
||||||
self.domain_information.save()
|
self.domain_information.save()
|
||||||
self.domain_information.refresh_from_db()
|
self.domain_information.refresh_from_db()
|
||||||
|
|
||||||
|
# Add a SO to the portfolio
|
||||||
senior_official = SeniorOfficial.objects.create(first_name="Bob", last_name="Unoriginal")
|
senior_official = SeniorOfficial.objects.create(first_name="Bob", last_name="Unoriginal")
|
||||||
portfolio.senior_official = senior_official
|
portfolio.senior_official = senior_official
|
||||||
portfolio.save()
|
portfolio.save()
|
||||||
portfolio.refresh_from_db()
|
portfolio.refresh_from_db()
|
||||||
|
|
||||||
# The page should contain the SO on portfolio
|
# The page should not contain the SO on domain information.
|
||||||
|
# However, the page should contain the SO on portfolio
|
||||||
page = self.app.get(reverse("domain-senior-official", kwargs={"pk": self.domain.id}))
|
page = self.app.get(reverse("domain-senior-official", kwargs={"pk": self.domain.id}))
|
||||||
self.assertNotContains(page, "Bob")
|
|
||||||
|
|
||||||
# Cleanup the portfolio and suborg
|
# Make sure that we're on the portfolio page.
|
||||||
portfolio.delete()
|
# This also implicity tests that the flag is working.
|
||||||
suborganization.delete()
|
self.assertContains(page, "Suborganization")
|
||||||
|
self.assertNotContains(page, "Organization name")
|
||||||
|
|
||||||
|
# Make sure that we're using the right SO value
|
||||||
|
self.assertNotContains(page, "Testy")
|
||||||
|
self.assertContains(page, "Bob")
|
||||||
|
|
||||||
def test_domain_edit_senior_official_in_place(self):
|
def test_domain_edit_senior_official_in_place(self):
|
||||||
"""When editing a senior official for domain information and SO is not
|
"""When editing a senior official for domain information and SO is not
|
||||||
|
|
|
@ -23,9 +23,9 @@ from registrar.models import (
|
||||||
DomainInvitation,
|
DomainInvitation,
|
||||||
User,
|
User,
|
||||||
UserDomainRole,
|
UserDomainRole,
|
||||||
|
Portfolio,
|
||||||
|
PublicContact,
|
||||||
)
|
)
|
||||||
from registrar.models.portfolio import Portfolio
|
|
||||||
from registrar.models.public_contact import PublicContact
|
|
||||||
from registrar.utility.enums import DefaultEmail
|
from registrar.utility.enums import DefaultEmail
|
||||||
from registrar.utility.errors import (
|
from registrar.utility.errors import (
|
||||||
GenericError,
|
GenericError,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue