mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-21 18:25:58 +02:00
Add unit tests + linting
This commit is contained in:
parent
b8b97245a4
commit
4830f5630f
2 changed files with 31 additions and 23 deletions
|
@ -33,6 +33,7 @@ def split_string(value, key):
|
||||||
"""
|
"""
|
||||||
return value.split(key)
|
return value.split(key)
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def public_site_url(url_path):
|
def public_site_url(url_path):
|
||||||
"""Make a full URL for this path at our public site.
|
"""Make a full URL for this path at our public site.
|
||||||
|
|
|
@ -1220,14 +1220,14 @@ class TestDomainRequestAdmin(MockEppLib):
|
||||||
self.assertContains(response, value, count=1)
|
self.assertContains(response, value, count=1)
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_other_contacts_readonly_has_link(self):
|
def test_other_contacts_has_readonly_link(self):
|
||||||
"""Tests if the readonly other_contacts field has links"""
|
"""Tests if the readonly other_contacts field has links"""
|
||||||
|
|
||||||
# Create a fake domain request
|
# Create a fake domain request
|
||||||
domain_request = completed_domain_request(
|
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
|
||||||
status=DomainRequest.DomainRequestStatus.IN_REVIEW,
|
|
||||||
user=_creator
|
# Get the other contact
|
||||||
)
|
other_contact = domain_request.other_contacts.all().first()
|
||||||
|
|
||||||
p = "userpass"
|
p = "userpass"
|
||||||
self.client.login(username="staffuser", password=p)
|
self.client.login(username="staffuser", password=p)
|
||||||
|
@ -1240,6 +1240,16 @@ class TestDomainRequestAdmin(MockEppLib):
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertContains(response, domain_request.requested_domain.name)
|
self.assertContains(response, domain_request.requested_domain.name)
|
||||||
|
|
||||||
|
# Check that the page contains the url we expect
|
||||||
|
expected_href = reverse("admin:registrar_contact_change", args=[other_contact.id])
|
||||||
|
self.assertContains(response, expected_href)
|
||||||
|
|
||||||
|
# Check that the page contains the link we expect.
|
||||||
|
# Since the url is dynamic (populated by JS), we can test for its existence
|
||||||
|
# by checking for the end tag.
|
||||||
|
expected_url = f"Testy Tester</a>"
|
||||||
|
self.assertContains(response, expected_url)
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_contact_fields_have_detail_table(self):
|
def test_contact_fields_have_detail_table(self):
|
||||||
"""Tests if the contact fields have the detail table which displays title, email, and phone"""
|
"""Tests if the contact fields have the detail table which displays title, email, and phone"""
|
||||||
|
@ -1247,8 +1257,8 @@ class TestDomainRequestAdmin(MockEppLib):
|
||||||
# Create fake creator
|
# Create fake creator
|
||||||
_creator = User.objects.create(
|
_creator = User.objects.create(
|
||||||
username="MrMeoward",
|
username="MrMeoward",
|
||||||
first_name = "Meoward",
|
first_name="Meoward",
|
||||||
last_name = "Jones",
|
last_name="Jones",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Due to the relation between User <==> Contact,
|
# Due to the relation between User <==> Contact,
|
||||||
|
@ -1259,10 +1269,7 @@ class TestDomainRequestAdmin(MockEppLib):
|
||||||
_creator.contact.save()
|
_creator.contact.save()
|
||||||
|
|
||||||
# Create a fake domain request
|
# Create a fake domain request
|
||||||
domain_request = completed_domain_request(
|
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW, user=_creator)
|
||||||
status=DomainRequest.DomainRequestStatus.IN_REVIEW,
|
|
||||||
user=_creator
|
|
||||||
)
|
|
||||||
|
|
||||||
p = "userpass"
|
p = "userpass"
|
||||||
self.client.login(username="staffuser", password=p)
|
self.client.login(username="staffuser", password=p)
|
||||||
|
@ -1279,7 +1286,6 @@ class TestDomainRequestAdmin(MockEppLib):
|
||||||
# Check for the header
|
# Check for the header
|
||||||
|
|
||||||
# == Check for the creator == #
|
# == Check for the creator == #
|
||||||
self.assertContains(response, "Meoward Jones")
|
|
||||||
|
|
||||||
# Check for the right title, email, and phone number in the response.
|
# Check for the right title, email, and phone number in the response.
|
||||||
# We only need to check for the end tag
|
# We only need to check for the end tag
|
||||||
|
@ -1288,31 +1294,32 @@ class TestDomainRequestAdmin(MockEppLib):
|
||||||
# Field, expected value
|
# Field, expected value
|
||||||
("title", "Treat inspector</td>"),
|
("title", "Treat inspector</td>"),
|
||||||
("email", "meoward.jones@igorville.gov</td>"),
|
("email", "meoward.jones@igorville.gov</td>"),
|
||||||
("phone", "(555) 123 12345</td>")
|
("phone", "(555) 123 12345</td>"),
|
||||||
]
|
]
|
||||||
self.assert_response_contains_distinct_values(response, expected_creator_fields)
|
self.assert_response_contains_distinct_values(response, expected_creator_fields)
|
||||||
|
|
||||||
# == Check for the submitter == #
|
# Check for the field itself
|
||||||
self.assertContains(response, "Testy2 Tester2")
|
self.assertContains(response, "Meoward Jones")
|
||||||
|
|
||||||
|
# == Check for the submitter == #
|
||||||
expected_submitter_fields = [
|
expected_submitter_fields = [
|
||||||
# Field, expected value
|
# Field, expected value
|
||||||
("title", "Admin Tester</td>"),
|
("title", "Admin Tester</td>"),
|
||||||
("email", "mayor@igorville.gov</td>"),
|
("email", "mayor@igorville.gov</td>"),
|
||||||
("phone", "(555) 555 5556</td>")
|
("phone", "(555) 555 5556</td>"),
|
||||||
]
|
]
|
||||||
self.assert_response_contains_distinct_values(response, expected_submitter_fields)
|
self.assert_response_contains_distinct_values(response, expected_submitter_fields)
|
||||||
|
self.assertContains(response, "Testy2 Tester2")
|
||||||
|
|
||||||
# == Check for the authorizing_official == #
|
# == Check for the authorizing_official == #
|
||||||
self.assertContains(response, "Testy Tester")
|
|
||||||
|
|
||||||
expected_ao_fields = [
|
expected_ao_fields = [
|
||||||
# Field, expected value
|
# Field, expected value
|
||||||
("title", "Chief Tester</td>"),
|
("title", "Chief Tester</td>"),
|
||||||
("email", "testy@town.com</td>"),
|
("email", "testy@town.com</td>"),
|
||||||
("phone", "(555) 555 5555</td>")
|
("phone", "(555) 555 5555</td>"),
|
||||||
]
|
]
|
||||||
self.assert_response_contains_distinct_values(response, expected_ao_fields)
|
self.assert_response_contains_distinct_values(response, expected_ao_fields)
|
||||||
|
self.assertContains(response, "Testy Tester")
|
||||||
|
|
||||||
# Check for table titles. We only need to check for the end tag
|
# Check for table titles. We only need to check for the end tag
|
||||||
# (Otherwise this test will fail if we change classes, etc)
|
# (Otherwise this test will fail if we change classes, etc)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue