mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-25 12:08:40 +02:00
Merge remote-tracking branch 'origin' into es/1793-link-federal-agency-table
This commit is contained in:
commit
dfda5b37d4
42 changed files with 1601 additions and 164 deletions
|
@ -21,6 +21,12 @@ from registrar.admin import (
|
|||
MyHostAdmin,
|
||||
UserDomainRoleAdmin,
|
||||
VerifiedByStaffAdmin,
|
||||
WebsiteAdmin,
|
||||
DraftDomainAdmin,
|
||||
FederalAgencyAdmin,
|
||||
PublicContactAdmin,
|
||||
TransitionDomainAdmin,
|
||||
UserGroupAdmin,
|
||||
)
|
||||
from registrar.models import (
|
||||
Domain,
|
||||
|
@ -33,6 +39,9 @@ from registrar.models import (
|
|||
PublicContact,
|
||||
Host,
|
||||
Website,
|
||||
FederalAgency,
|
||||
UserGroup,
|
||||
TransitionDomain,
|
||||
)
|
||||
from registrar.models.user_domain_role import UserDomainRole
|
||||
from registrar.models.verified_by_staff import VerifiedByStaff
|
||||
|
@ -95,6 +104,89 @@ class TestDomainAdmin(MockEppLib, WebTest):
|
|||
)
|
||||
super().setUp()
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_staff_can_see_cisa_region_federal(self):
|
||||
"""Tests if staff can see CISA Region: N/A"""
|
||||
|
||||
# Create a fake domain request
|
||||
_domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
|
||||
_domain_request.approve()
|
||||
|
||||
domain = _domain_request.approved_domain
|
||||
p = "userpass"
|
||||
self.client.login(username="staffuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domain/{}/change/".format(domain.pk),
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure the page loaded, and that we're on the right page
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, domain.name)
|
||||
|
||||
# Test if the page has the right CISA region
|
||||
expected_html = '<div class="flex-container margin-top-2"><span>CISA region: N/A</span></div>'
|
||||
# Remove whitespace from expected_html
|
||||
expected_html = "".join(expected_html.split())
|
||||
|
||||
# Remove whitespace from response content
|
||||
response_content = "".join(response.content.decode().split())
|
||||
|
||||
# Check if response contains expected_html
|
||||
self.assertIn(expected_html, response_content)
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_staff_can_see_cisa_region_non_federal(self):
|
||||
"""Tests if staff can see the correct CISA region"""
|
||||
|
||||
# Create a fake domain request. State will be NY (2).
|
||||
_domain_request = completed_domain_request(
|
||||
status=DomainRequest.DomainRequestStatus.IN_REVIEW, generic_org_type="interstate"
|
||||
)
|
||||
|
||||
_domain_request.approve()
|
||||
|
||||
domain = _domain_request.approved_domain
|
||||
|
||||
p = "userpass"
|
||||
self.client.login(username="staffuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domain/{}/change/".format(domain.pk),
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure the page loaded, and that we're on the right page
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, domain.name)
|
||||
|
||||
# Test if the page has the right CISA region
|
||||
expected_html = '<div class="flex-container margin-top-2"><span>CISA region: 2</span></div>'
|
||||
# Remove whitespace from expected_html
|
||||
expected_html = "".join(expected_html.split())
|
||||
|
||||
# Remove whitespace from response content
|
||||
response_content = "".join(response.content.decode().split())
|
||||
|
||||
# Check if response contains expected_html
|
||||
self.assertIn(expected_html, response_content)
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_has_model_description(self):
|
||||
"""Tests if this model has a model description on the table view"""
|
||||
p = "adminpass"
|
||||
self.client.login(username="superuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domain/",
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure that the page is loaded correctly
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test for a description snippet
|
||||
self.assertContains(response, "This table contains all approved domains in the .gov registrar.")
|
||||
self.assertContains(response, "Show more")
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_contact_fields_on_domain_change_form_have_detail_table(self):
|
||||
"""Tests if the contact fields in the inlined Domain information have the detail table
|
||||
|
@ -511,7 +603,7 @@ class TestDomainAdmin(MockEppLib, WebTest):
|
|||
|
||||
# There are 4 template references to Federal (4) plus four references in the table
|
||||
# for our actual domain_request
|
||||
self.assertContains(response, "Federal", count=36)
|
||||
self.assertContains(response, "Federal", count=42)
|
||||
# This may be a bit more robust
|
||||
self.assertContains(response, '<td class="field-generic_org_type">Federal</td>', count=1)
|
||||
# Now let's make sure the long description does not exist
|
||||
|
@ -852,6 +944,23 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
)
|
||||
self.mock_client = MockSESClient()
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_has_model_description(self):
|
||||
"""Tests if this model has a model description on the table view"""
|
||||
p = "adminpass"
|
||||
self.client.login(username="superuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domainrequest/",
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure that the page is loaded correctly
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test for a description snippet
|
||||
self.assertContains(response, "This table contains all domain requests")
|
||||
self.assertContains(response, "Show more")
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_helper_text(self):
|
||||
"""
|
||||
|
@ -888,6 +997,96 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
self.test_helper.assert_response_contains_distinct_values(response, expected_values)
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_status_logs(self):
|
||||
"""
|
||||
Tests that the status changes are shown in a table on the domain request change form,
|
||||
accurately and in chronological order.
|
||||
"""
|
||||
|
||||
# Create a fake domain request and domain
|
||||
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.STARTED)
|
||||
|
||||
p = "adminpass"
|
||||
self.client.login(username="superuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domainrequest/{}/change/".format(domain_request.pk),
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure the page loaded, and that we're on the right page
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, domain_request.requested_domain.name)
|
||||
|
||||
# Table will contain one row for Started
|
||||
self.assertContains(response, "<td>Started</td>", count=1)
|
||||
self.assertNotContains(response, "<td>Submitted</td>")
|
||||
|
||||
domain_request.submit()
|
||||
domain_request.save()
|
||||
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domainrequest/{}/change/".format(domain_request.pk),
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Table will contain and extra row for Submitted
|
||||
self.assertContains(response, "<td>Started</td>", count=1)
|
||||
self.assertContains(response, "<td>Submitted</td>", count=1)
|
||||
|
||||
domain_request.in_review()
|
||||
domain_request.save()
|
||||
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domainrequest/{}/change/".format(domain_request.pk),
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Table will contain and extra row for In review
|
||||
self.assertContains(response, "<td>Started</td>", count=1)
|
||||
self.assertContains(response, "<td>Submitted</td>", count=1)
|
||||
self.assertContains(response, "<td>In review</td>", count=1)
|
||||
|
||||
domain_request.action_needed()
|
||||
domain_request.save()
|
||||
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domainrequest/{}/change/".format(domain_request.pk),
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Table will contain and extra row for Action needed
|
||||
self.assertContains(response, "<td>Started</td>", count=1)
|
||||
self.assertContains(response, "<td>Submitted</td>", count=1)
|
||||
self.assertContains(response, "<td>In review</td>", count=1)
|
||||
self.assertContains(response, "<td>Action needed</td>", count=1)
|
||||
|
||||
domain_request.in_review()
|
||||
domain_request.save()
|
||||
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domainrequest/{}/change/".format(domain_request.pk),
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Define the expected sequence of status changes
|
||||
expected_status_changes = [
|
||||
"<td>In review</td>",
|
||||
"<td>Action needed</td>",
|
||||
"<td>In review</td>",
|
||||
"<td>Submitted</td>",
|
||||
"<td>Started</td>",
|
||||
]
|
||||
|
||||
# Test for the order of status changes
|
||||
for status_change in expected_status_changes:
|
||||
self.assertContains(response, status_change, html=True)
|
||||
|
||||
# Table now contains 2 rows for Approved
|
||||
self.assertContains(response, "<td>Started</td>", count=1)
|
||||
self.assertContains(response, "<td>Submitted</td>", count=1)
|
||||
self.assertContains(response, "<td>In review</td>", count=2)
|
||||
self.assertContains(response, "<td>Action needed</td>", count=1)
|
||||
|
||||
def test_collaspe_toggle_button_markup(self):
|
||||
"""
|
||||
Tests for the correct collapse toggle button markup
|
||||
|
@ -906,7 +1105,6 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
# Make sure the page loaded, and that we're on the right page
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, domain_request.requested_domain.name)
|
||||
|
||||
self.test_helper.assertContains(response, "<span>Show details</span>")
|
||||
|
||||
@less_console_noise_decorator
|
||||
|
@ -1178,7 +1376,7 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
response = self.client.get("/admin/registrar/domainrequest/?generic_org_type__exact=federal")
|
||||
# There are 2 template references to Federal (4) and two in the results data
|
||||
# of the request
|
||||
self.assertContains(response, "Federal", count=34)
|
||||
self.assertContains(response, "Federal", count=40)
|
||||
# This may be a bit more robust
|
||||
self.assertContains(response, '<td class="field-generic_org_type">Federal</td>', count=1)
|
||||
# Now let's make sure the long description does not exist
|
||||
|
@ -1797,7 +1995,7 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
self.assertContains(response, domain_request.requested_domain.name)
|
||||
|
||||
# Check that the page contains the link we expect.
|
||||
expected_url = '<a href="city.com" class="padding-top-1 current-website__1">city.com</a>'
|
||||
expected_url = '<a href="city.com" target="_blank" class="padding-top-1 current-website__1">city.com</a>'
|
||||
self.assertContains(response, expected_url)
|
||||
|
||||
@less_console_noise_decorator
|
||||
|
@ -2390,6 +2588,66 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
|
||||
self.assertEqual(expected_list, actual_list)
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_staff_can_see_cisa_region_federal(self):
|
||||
"""Tests if staff can see CISA Region: N/A"""
|
||||
|
||||
# Create a fake domain request
|
||||
_domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
|
||||
|
||||
p = "userpass"
|
||||
self.client.login(username="staffuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domainrequest/{}/change/".format(_domain_request.pk),
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure the page loaded, and that we're on the right page
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, _domain_request.requested_domain.name)
|
||||
|
||||
# Test if the page has the right CISA region
|
||||
expected_html = '<div class="flex-container margin-top-2"><span>CISA region: N/A</span></div>'
|
||||
# Remove whitespace from expected_html
|
||||
expected_html = "".join(expected_html.split())
|
||||
|
||||
# Remove whitespace from response content
|
||||
response_content = "".join(response.content.decode().split())
|
||||
|
||||
# Check if response contains expected_html
|
||||
self.assertIn(expected_html, response_content)
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_staff_can_see_cisa_region_non_federal(self):
|
||||
"""Tests if staff can see the correct CISA region"""
|
||||
|
||||
# Create a fake domain request. State will be NY (2).
|
||||
_domain_request = completed_domain_request(
|
||||
status=DomainRequest.DomainRequestStatus.IN_REVIEW, generic_org_type="interstate"
|
||||
)
|
||||
|
||||
p = "userpass"
|
||||
self.client.login(username="staffuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domainrequest/{}/change/".format(_domain_request.pk),
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure the page loaded, and that we're on the right page
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, _domain_request.requested_domain.name)
|
||||
|
||||
# Test if the page has the right CISA region
|
||||
expected_html = '<div class="flex-container margin-top-2"><span>CISA region: 2</span></div>'
|
||||
# Remove whitespace from expected_html
|
||||
expected_html = "".join(expected_html.split())
|
||||
|
||||
# Remove whitespace from response content
|
||||
response_content = "".join(response.content.decode().split())
|
||||
|
||||
# Check if response contains expected_html
|
||||
self.assertIn(expected_html, response_content)
|
||||
|
||||
def tearDown(self):
|
||||
super().tearDown()
|
||||
Domain.objects.all().delete()
|
||||
|
@ -2401,7 +2659,7 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
self.mock_client.EMAILS_SENT.clear()
|
||||
|
||||
|
||||
class DomainInvitationAdminTest(TestCase):
|
||||
class TestDomainInvitationAdmin(TestCase):
|
||||
"""Tests for the DomainInvitation page"""
|
||||
|
||||
def setUp(self):
|
||||
|
@ -2417,6 +2675,25 @@ class DomainInvitationAdminTest(TestCase):
|
|||
User.objects.all().delete()
|
||||
Contact.objects.all().delete()
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_has_model_description(self):
|
||||
"""Tests if this model has a model description on the table view"""
|
||||
p = "adminpass"
|
||||
self.client.login(username="superuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domaininvitation/",
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure that the page is loaded correctly
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test for a description snippet
|
||||
self.assertContains(
|
||||
response, "Domain invitations contain all individuals who have been invited to manage a .gov domain."
|
||||
)
|
||||
self.assertContains(response, "Show more")
|
||||
|
||||
def test_get_filters(self):
|
||||
"""Ensures that our filters are displaying correctly"""
|
||||
with less_console_noise():
|
||||
|
@ -2431,7 +2708,7 @@ class DomainInvitationAdminTest(TestCase):
|
|||
)
|
||||
|
||||
# Assert that the filters are added
|
||||
self.assertContains(response, "invited", count=2)
|
||||
self.assertContains(response, "invited", count=4)
|
||||
self.assertContains(response, "Invited", count=2)
|
||||
self.assertContains(response, "retrieved", count=2)
|
||||
self.assertContains(response, "Retrieved", count=2)
|
||||
|
@ -2466,6 +2743,23 @@ class TestHostAdmin(TestCase):
|
|||
Host.objects.all().delete()
|
||||
Domain.objects.all().delete()
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_has_model_description(self):
|
||||
"""Tests if this model has a model description on the table view"""
|
||||
p = "adminpass"
|
||||
self.client.login(username="superuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/host/",
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure that the page is loaded correctly
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test for a description snippet
|
||||
self.assertContains(response, "Entries in the Hosts table indicate the relationship between an approved domain")
|
||||
self.assertContains(response, "Show more")
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_helper_text(self):
|
||||
"""
|
||||
|
@ -2544,6 +2838,88 @@ class TestDomainInformationAdmin(TestCase):
|
|||
Contact.objects.all().delete()
|
||||
User.objects.all().delete()
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_admin_can_see_cisa_region_federal(self):
|
||||
"""Tests if admins can see CISA Region: N/A"""
|
||||
|
||||
# Create a fake domain request
|
||||
_domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
|
||||
_domain_request.approve()
|
||||
|
||||
domain_information = DomainInformation.objects.filter(domain_request=_domain_request).get()
|
||||
|
||||
p = "adminpass"
|
||||
self.client.login(username="superuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domaininformation/{}/change/".format(domain_information.pk),
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure the page loaded, and that we're on the right page
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, domain_information.domain.name)
|
||||
|
||||
# Test if the page has the right CISA region
|
||||
expected_html = '<div class="flex-container margin-top-2"><span>CISA region: N/A</span></div>'
|
||||
# Remove whitespace from expected_html
|
||||
expected_html = "".join(expected_html.split())
|
||||
|
||||
# Remove whitespace from response content
|
||||
response_content = "".join(response.content.decode().split())
|
||||
|
||||
# Check if response contains expected_html
|
||||
self.assertIn(expected_html, response_content)
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_admin_can_see_cisa_region_non_federal(self):
|
||||
"""Tests if admins can see the correct CISA region"""
|
||||
|
||||
# Create a fake domain request. State will be NY (2).
|
||||
_domain_request = completed_domain_request(
|
||||
status=DomainRequest.DomainRequestStatus.IN_REVIEW, generic_org_type="interstate"
|
||||
)
|
||||
_domain_request.approve()
|
||||
|
||||
domain_information = DomainInformation.objects.filter(domain_request=_domain_request).get()
|
||||
p = "adminpass"
|
||||
self.client.login(username="superuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domaininformation/{}/change/".format(domain_information.pk),
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure the page loaded, and that we're on the right page
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, domain_information.domain.name)
|
||||
|
||||
# Test if the page has the right CISA region
|
||||
expected_html = '<div class="flex-container margin-top-2"><span>CISA region: 2</span></div>'
|
||||
# Remove whitespace from expected_html
|
||||
expected_html = "".join(expected_html.split())
|
||||
|
||||
# Remove whitespace from response content
|
||||
response_content = "".join(response.content.decode().split())
|
||||
|
||||
# Check if response contains expected_html
|
||||
self.assertIn(expected_html, response_content)
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_has_model_description(self):
|
||||
"""Tests if this model has a model description on the table view"""
|
||||
p = "adminpass"
|
||||
self.client.login(username="superuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/domaininformation/",
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure that the page is loaded correctly
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test for a description snippet
|
||||
self.assertContains(response, "Domain information represents the basic metadata")
|
||||
self.assertContains(response, "Show more")
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_helper_text(self):
|
||||
"""
|
||||
|
@ -2787,7 +3163,7 @@ class TestDomainInformationAdmin(TestCase):
|
|||
self.test_helper.assert_table_sorted("-4", ("-submitter__first_name", "-submitter__last_name"))
|
||||
|
||||
|
||||
class UserDomainRoleAdminTest(TestCase):
|
||||
class TestUserDomainRoleAdmin(TestCase):
|
||||
def setUp(self):
|
||||
"""Setup environment for a mock admin user"""
|
||||
self.site = AdminSite()
|
||||
|
@ -2809,6 +3185,25 @@ class UserDomainRoleAdminTest(TestCase):
|
|||
Domain.objects.all().delete()
|
||||
UserDomainRole.objects.all().delete()
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_has_model_description(self):
|
||||
"""Tests if this model has a model description on the table view"""
|
||||
p = "adminpass"
|
||||
self.client.login(username="superuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/userdomainrole/",
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure that the page is loaded correctly
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test for a description snippet
|
||||
self.assertContains(
|
||||
response, "This table represents the managers who are assigned to each domain in the registrar"
|
||||
)
|
||||
self.assertContains(response, "Show more")
|
||||
|
||||
def test_domain_sortable(self):
|
||||
"""Tests if the UserDomainrole sorts by domain correctly"""
|
||||
with less_console_noise():
|
||||
|
@ -3005,6 +3400,23 @@ class TestMyUserAdmin(TestCase):
|
|||
super().tearDown()
|
||||
User.objects.all().delete()
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_has_model_description(self):
|
||||
"""Tests if this model has a model description on the table view"""
|
||||
p = "adminpass"
|
||||
self.client.login(username="superuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/user/",
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure that the page is loaded correctly
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test for a description snippet
|
||||
self.assertContains(response, "A user is anyone who has access to the registrar.")
|
||||
self.assertContains(response, "Show more")
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_helper_text(self):
|
||||
"""
|
||||
|
@ -3439,7 +3851,7 @@ class DomainSessionVariableTest(TestCase):
|
|||
)
|
||||
|
||||
|
||||
class ContactAdminTest(TestCase):
|
||||
class TestContactAdmin(TestCase):
|
||||
def setUp(self):
|
||||
self.site = AdminSite()
|
||||
self.factory = RequestFactory()
|
||||
|
@ -3448,6 +3860,23 @@ class ContactAdminTest(TestCase):
|
|||
self.superuser = create_superuser()
|
||||
self.staffuser = create_user()
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_has_model_description(self):
|
||||
"""Tests if this model has a model description on the table view"""
|
||||
p = "adminpass"
|
||||
self.client.login(username="superuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/contact/",
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure that the page is loaded correctly
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test for a description snippet
|
||||
self.assertContains(response, "Contacts include anyone who has access to the registrar (known as “users”)")
|
||||
self.assertContains(response, "Show more")
|
||||
|
||||
def test_readonly_when_restricted_staffuser(self):
|
||||
with less_console_noise():
|
||||
request = self.factory.get("/")
|
||||
|
@ -3566,6 +3995,25 @@ class TestVerifiedByStaffAdmin(TestCase):
|
|||
VerifiedByStaff.objects.all().delete()
|
||||
User.objects.all().delete()
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_has_model_description(self):
|
||||
"""Tests if this model has a model description on the table view"""
|
||||
p = "adminpass"
|
||||
self.client.login(username="superuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/verifiedbystaff/",
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure that the page is loaded correctly
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test for a description snippet
|
||||
self.assertContains(
|
||||
response, "This table contains users who have been allowed to bypass " "identity proofing through Login.gov"
|
||||
)
|
||||
self.assertContains(response, "Show more")
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_helper_text(self):
|
||||
"""
|
||||
|
@ -3608,3 +4056,204 @@ class TestVerifiedByStaffAdmin(TestCase):
|
|||
|
||||
# Check that the user field is set to the request.user
|
||||
self.assertEqual(vip_instance.requestor, self.superuser)
|
||||
|
||||
|
||||
class TestWebsiteAdmin(TestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.site = AdminSite()
|
||||
self.superuser = create_superuser()
|
||||
self.admin = WebsiteAdmin(model=Website, admin_site=self.site)
|
||||
self.factory = RequestFactory()
|
||||
self.client = Client(HTTP_HOST="localhost:8080")
|
||||
self.test_helper = GenericTestHelper(admin=self.admin)
|
||||
|
||||
def tearDown(self):
|
||||
super().tearDown()
|
||||
Website.objects.all().delete()
|
||||
User.objects.all().delete()
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_has_model_description(self):
|
||||
"""Tests if this model has a model description on the table view"""
|
||||
p = "adminpass"
|
||||
self.client.login(username="superuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/website/",
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure that the page is loaded correctly
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test for a description snippet
|
||||
self.assertContains(response, "This table lists all the “current websites” and “alternative domains”")
|
||||
self.assertContains(response, "Show more")
|
||||
|
||||
|
||||
class TestDraftDomain(TestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.site = AdminSite()
|
||||
self.superuser = create_superuser()
|
||||
self.admin = DraftDomainAdmin(model=DraftDomain, admin_site=self.site)
|
||||
self.factory = RequestFactory()
|
||||
self.client = Client(HTTP_HOST="localhost:8080")
|
||||
self.test_helper = GenericTestHelper(admin=self.admin)
|
||||
|
||||
def tearDown(self):
|
||||
super().tearDown()
|
||||
DraftDomain.objects.all().delete()
|
||||
User.objects.all().delete()
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_has_model_description(self):
|
||||
"""Tests if this model has a model description on the table view"""
|
||||
p = "adminpass"
|
||||
self.client.login(username="superuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/draftdomain/",
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure that the page is loaded correctly
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test for a description snippet
|
||||
self.assertContains(
|
||||
response, "This table represents all “requested domains” that have been saved within a domain"
|
||||
)
|
||||
self.assertContains(response, "Show more")
|
||||
|
||||
|
||||
class TestFederalAgency(TestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.site = AdminSite()
|
||||
self.superuser = create_superuser()
|
||||
self.admin = FederalAgencyAdmin(model=FederalAgency, admin_site=self.site)
|
||||
self.factory = RequestFactory()
|
||||
self.client = Client(HTTP_HOST="localhost:8080")
|
||||
self.test_helper = GenericTestHelper(admin=self.admin)
|
||||
|
||||
def tearDown(self):
|
||||
super().tearDown()
|
||||
FederalAgency.objects.all().delete()
|
||||
User.objects.all().delete()
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_has_model_description(self):
|
||||
"""Tests if this model has a model description on the table view"""
|
||||
p = "adminpass"
|
||||
self.client.login(username="superuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/federalagency/",
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure that the page is loaded correctly
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test for a description snippet
|
||||
self.assertContains(response, "This table does not have a description yet.")
|
||||
self.assertContains(response, "Show more")
|
||||
|
||||
|
||||
class TestPublicContact(TestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.site = AdminSite()
|
||||
self.superuser = create_superuser()
|
||||
self.admin = PublicContactAdmin(model=PublicContact, admin_site=self.site)
|
||||
self.factory = RequestFactory()
|
||||
self.client = Client(HTTP_HOST="localhost:8080")
|
||||
self.test_helper = GenericTestHelper(admin=self.admin)
|
||||
|
||||
def tearDown(self):
|
||||
super().tearDown()
|
||||
PublicContact.objects.all().delete()
|
||||
User.objects.all().delete()
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_has_model_description(self):
|
||||
"""Tests if this model has a model description on the table view"""
|
||||
p = "adminpass"
|
||||
self.client.login(username="superuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/publiccontact/",
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure that the page is loaded correctly
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test for a description snippet
|
||||
self.assertContains(response, "Public contacts represent the three registry contact types")
|
||||
self.assertContains(response, "Show more")
|
||||
|
||||
|
||||
class TestTransitionDomain(TestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.site = AdminSite()
|
||||
self.superuser = create_superuser()
|
||||
self.admin = TransitionDomainAdmin(model=TransitionDomain, admin_site=self.site)
|
||||
self.factory = RequestFactory()
|
||||
self.client = Client(HTTP_HOST="localhost:8080")
|
||||
self.test_helper = GenericTestHelper(admin=self.admin)
|
||||
|
||||
def tearDown(self):
|
||||
super().tearDown()
|
||||
PublicContact.objects.all().delete()
|
||||
User.objects.all().delete()
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_has_model_description(self):
|
||||
"""Tests if this model has a model description on the table view"""
|
||||
p = "adminpass"
|
||||
self.client.login(username="superuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/transitiondomain/",
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure that the page is loaded correctly
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test for a description snippet
|
||||
self.assertContains(response, "This table represents the domains that were transitioned from the old registry")
|
||||
self.assertContains(response, "Show more")
|
||||
|
||||
|
||||
class TestUserGroup(TestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.site = AdminSite()
|
||||
self.superuser = create_superuser()
|
||||
self.admin = UserGroupAdmin(model=UserGroup, admin_site=self.site)
|
||||
self.factory = RequestFactory()
|
||||
self.client = Client(HTTP_HOST="localhost:8080")
|
||||
self.test_helper = GenericTestHelper(admin=self.admin)
|
||||
|
||||
def tearDown(self):
|
||||
super().tearDown()
|
||||
User.objects.all().delete()
|
||||
|
||||
@less_console_noise_decorator
|
||||
def test_has_model_description(self):
|
||||
"""Tests if this model has a model description on the table view"""
|
||||
p = "adminpass"
|
||||
self.client.login(username="superuser", password=p)
|
||||
response = self.client.get(
|
||||
"/admin/registrar/usergroup/",
|
||||
follow=True,
|
||||
)
|
||||
|
||||
# Make sure that the page is loaded correctly
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test for a description snippet
|
||||
self.assertContains(
|
||||
response, "Groups are a way to bundle admin permissions so they can be easily assigned to multiple users."
|
||||
)
|
||||
self.assertContains(response, "Show more")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue