mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-21 10:16:13 +02:00
Test cases
This commit is contained in:
parent
528c77a8b3
commit
6de09d5bb8
1 changed files with 45 additions and 0 deletions
|
@ -322,6 +322,7 @@ class TestDomainApplicationAdmin(MockEppLib):
|
||||||
self.admin = DomainApplicationAdmin(model=DomainApplication, admin_site=self.site)
|
self.admin = DomainApplicationAdmin(model=DomainApplication, admin_site=self.site)
|
||||||
self.superuser = create_superuser()
|
self.superuser = create_superuser()
|
||||||
self.staffuser = create_user()
|
self.staffuser = create_user()
|
||||||
|
self.client = Client(HTTP_HOST="localhost:8080")
|
||||||
|
|
||||||
def test_short_org_name_in_applications_list(self):
|
def test_short_org_name_in_applications_list(self):
|
||||||
"""
|
"""
|
||||||
|
@ -842,6 +843,50 @@ class TestDomainApplicationAdmin(MockEppLib):
|
||||||
with self.assertRaises(DomainInformation.DoesNotExist):
|
with self.assertRaises(DomainInformation.DoesNotExist):
|
||||||
domain_information.refresh_from_db()
|
domain_information.refresh_from_db()
|
||||||
|
|
||||||
|
def test_has_correct_filters(self):
|
||||||
|
"""Tests if DomainApplicationAdmin has the correct filters"""
|
||||||
|
request = self.factory.get("/")
|
||||||
|
request.user = self.superuser
|
||||||
|
|
||||||
|
readonly_fields = self.admin.get_list_filter(request)
|
||||||
|
expected_fields = ("status", "organization_type", DomainApplicationAdmin.InvestigatorFilter)
|
||||||
|
|
||||||
|
self.assertEqual(readonly_fields, expected_fields)
|
||||||
|
|
||||||
|
def test_displays_investigator_filter(self):
|
||||||
|
"""Tests if DomainApplicationAdmin displays the investigator filter"""
|
||||||
|
p = "userpass"
|
||||||
|
self.client.login(username="staffuser", password=p)
|
||||||
|
response = self.client.get(
|
||||||
|
"/admin/registrar/domainapplication/",
|
||||||
|
{},
|
||||||
|
follow=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
expected_sort_column = "sortable column-investigator"
|
||||||
|
self.assertContains(response, expected_sort_column, count=1)
|
||||||
|
|
||||||
|
def test_investigator_filter(self):
|
||||||
|
"""Tests the custom investigator filter"""
|
||||||
|
# Creates multiple domain applications
|
||||||
|
multiple_unalphabetical_domain_objects("application")
|
||||||
|
p = "userpass"
|
||||||
|
self.client.login(username="staffuser", password=p)
|
||||||
|
|
||||||
|
response = self.client.get(
|
||||||
|
"/admin/registrar/domainapplication/",
|
||||||
|
{
|
||||||
|
"investigator": 1,
|
||||||
|
},
|
||||||
|
follow=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# The "multiple_unalphabetical_domain_objects" function will create
|
||||||
|
# user objects with a first name that contains "first_name:investigator".
|
||||||
|
# We can simply count how many times this appears in the table to determine
|
||||||
|
# how many records exist.
|
||||||
|
self.assertContains(response, "first_name:investigator", count=1)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super().tearDown()
|
super().tearDown()
|
||||||
Domain.objects.all().delete()
|
Domain.objects.all().delete()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue