mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-25 12:08:40 +02:00
revise unit tests
This commit is contained in:
parent
6631736315
commit
16a03d8f90
2 changed files with 69 additions and 1 deletions
|
@ -58,6 +58,8 @@ class GetDomainsJsonTest(TestWithUser, WebTest):
|
|||
state_displays = [domain["state_display"] for domain in data["domains"]]
|
||||
get_state_help_texts = [domain["get_state_help_text"] for domain in data["domains"]]
|
||||
action_urls = [domain["action_url"] for domain in data["domains"]]
|
||||
action_labels = [domain["action_label"] for domain in data["domains"]]
|
||||
svg_icons = [domain["svg_icon"] for domain in data["domains"]]
|
||||
|
||||
# Check fields for each domain
|
||||
for i, expected_domain in enumerate(expected_domains):
|
||||
|
@ -76,6 +78,30 @@ class GetDomainsJsonTest(TestWithUser, WebTest):
|
|||
|
||||
self.assertEqual(f"/domain/{expected_domain.id}", action_urls[i])
|
||||
|
||||
# Check action_label
|
||||
action_label_expected = (
|
||||
"View"
|
||||
if expected_domains[i].state
|
||||
in [
|
||||
Domain.State.DELETED,
|
||||
Domain.State.ON_HOLD,
|
||||
]
|
||||
else "Manage"
|
||||
)
|
||||
self.assertEqual(action_label_expected, action_labels[i])
|
||||
|
||||
# Check svg_icon
|
||||
svg_icon_expected = (
|
||||
"visibility"
|
||||
if expected_domains[i].state
|
||||
in [
|
||||
Domain.State.DELETED,
|
||||
Domain.State.ON_HOLD,
|
||||
]
|
||||
else "settings"
|
||||
)
|
||||
self.assertEqual(svg_icon_expected, svg_icons[i])
|
||||
|
||||
def test_pagination(self):
|
||||
"""Test that pagination is correct in the response"""
|
||||
response = self.app.get(reverse("get_domains_json"), {"page": 1})
|
||||
|
|
|
@ -5,7 +5,7 @@ from django_webtest import WebTest # type: ignore
|
|||
from django.utils.dateparse import parse_datetime
|
||||
|
||||
|
||||
class DomainRequestViewTest(TestWithUser, WebTest):
|
||||
class GetRequestsJsonTest(TestWithUser, WebTest):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.app.set_user(self.user.username)
|
||||
|
@ -131,6 +131,9 @@ class DomainRequestViewTest(TestWithUser, WebTest):
|
|||
created_ats = [request["created_at"] for request in data["domain_requests"]]
|
||||
ids = [request["id"] for request in data["domain_requests"]]
|
||||
is_deletables = [request["is_deletable"] for request in data["domain_requests"]]
|
||||
action_urls = [request["action_url"] for request in data["domain_requests"]]
|
||||
action_labels = [request["action_label"] for request in data["domain_requests"]]
|
||||
svg_icons = [request["svg_icon"] for request in data["domain_requests"]]
|
||||
|
||||
# Check fields for each domain request
|
||||
for i in range(10):
|
||||
|
@ -153,6 +156,45 @@ class DomainRequestViewTest(TestWithUser, WebTest):
|
|||
]
|
||||
self.assertEqual(is_deletable_expected, is_deletables[i])
|
||||
|
||||
# Check action_url
|
||||
action_url_expected = (
|
||||
f"/domain-request/{self.domain_requests[i].id}/edit"
|
||||
if self.domain_requests[i].status
|
||||
in [
|
||||
DomainRequest.DomainRequestStatus.STARTED,
|
||||
DomainRequest.DomainRequestStatus.ACTION_NEEDED,
|
||||
DomainRequest.DomainRequestStatus.WITHDRAWN,
|
||||
]
|
||||
else f"/domain-request/{self.domain_requests[i].id}"
|
||||
)
|
||||
self.assertEqual(action_url_expected, action_urls[i])
|
||||
|
||||
# Check action_label
|
||||
action_label_expected = (
|
||||
"Edit"
|
||||
if self.domain_requests[i].status
|
||||
in [
|
||||
DomainRequest.DomainRequestStatus.STARTED,
|
||||
DomainRequest.DomainRequestStatus.ACTION_NEEDED,
|
||||
DomainRequest.DomainRequestStatus.WITHDRAWN,
|
||||
]
|
||||
else "Manage"
|
||||
)
|
||||
self.assertEqual(action_label_expected, action_labels[i])
|
||||
|
||||
# Check svg_icon
|
||||
svg_icon_expected = (
|
||||
"edit"
|
||||
if self.domain_requests[i].status
|
||||
in [
|
||||
DomainRequest.DomainRequestStatus.STARTED,
|
||||
DomainRequest.DomainRequestStatus.ACTION_NEEDED,
|
||||
DomainRequest.DomainRequestStatus.WITHDRAWN,
|
||||
]
|
||||
else "settings"
|
||||
)
|
||||
self.assertEqual(svg_icon_expected, svg_icons[i])
|
||||
|
||||
def test_pagination(self):
|
||||
"""Test that pagination works properly. There are 11 total non-approved requests and
|
||||
a page size of 10"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue