mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-19 02:49:21 +02:00
Merge pull request #2137 from cisagov/za/2095-show-domain-cisa-region
Ticket #2095: Add unit tests for domain cisa region
This commit is contained in:
commit
aa9ec2d716
1 changed files with 131 additions and 0 deletions
|
@ -104,6 +104,72 @@ class TestDomainAdmin(MockEppLib, WebTest):
|
||||||
)
|
)
|
||||||
super().setUp()
|
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
|
@less_console_noise_decorator
|
||||||
def test_has_model_description(self):
|
def test_has_model_description(self):
|
||||||
"""Tests if this model has a model description on the table view"""
|
"""Tests if this model has a model description on the table view"""
|
||||||
|
@ -2774,6 +2840,71 @@ class TestDomainInformationAdmin(TestCase):
|
||||||
Contact.objects.all().delete()
|
Contact.objects.all().delete()
|
||||||
User.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
|
@less_console_noise_decorator
|
||||||
def test_has_model_description(self):
|
def test_has_model_description(self):
|
||||||
"""Tests if this model has a model description on the table view"""
|
"""Tests if this model has a model description on the table view"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue