mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-15 17:17:02 +02:00
Update test_admin.py
This commit is contained in:
parent
1b688b4abd
commit
b6cb72aabb
1 changed files with 41 additions and 39 deletions
|
@ -316,6 +316,47 @@ class TestDomainApplicationAdminForm(TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestDomainApplicationAdminTable(MockEppLib):
|
||||||
|
"""Tests the table for DomainApplicationAdmin"""
|
||||||
|
def setUp(self):
|
||||||
|
"""Enables epplib patching, and creates a fake admin object"""
|
||||||
|
super().setUp()
|
||||||
|
self.site = AdminSite()
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
self.superuser = create_superuser()
|
||||||
|
self.admin = DomainApplicationAdmin(model=DomainApplication, admin_site=self.site)
|
||||||
|
|
||||||
|
def test_table_sorted_alphabetically(self):
|
||||||
|
"""Tests if DomainApplicationAdmin table is sorted alphabetically"""
|
||||||
|
# Creates a list of DomainApplications in scrambled order
|
||||||
|
multiple_unalphabetical_domain_objects("application")
|
||||||
|
|
||||||
|
request = self.factory.get("/")
|
||||||
|
request.user = self.superuser
|
||||||
|
|
||||||
|
# Get the expected list of alphabetically sorted DomainApplications
|
||||||
|
expected_order = DomainApplication.objects.order_by("requested_domain__name")
|
||||||
|
|
||||||
|
# Get the returned queryset
|
||||||
|
queryset = self.admin.get_queryset(request)
|
||||||
|
|
||||||
|
# Check the order
|
||||||
|
self.assertEqual(
|
||||||
|
list(queryset),
|
||||||
|
list(expected_order),
|
||||||
|
)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
"""Delete all associated domain objects"""
|
||||||
|
super().tearDown()
|
||||||
|
Domain.objects.all().delete()
|
||||||
|
DomainInformation.objects.all().delete()
|
||||||
|
DomainApplication.objects.all().delete()
|
||||||
|
User.objects.all().delete()
|
||||||
|
Contact.objects.all().delete()
|
||||||
|
Website.objects.all().delete()
|
||||||
|
|
||||||
|
|
||||||
class TestDomainApplicationAdmin(MockEppLib):
|
class TestDomainApplicationAdmin(MockEppLib):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
@ -957,45 +998,6 @@ class TestDomainApplicationAdmin(MockEppLib):
|
||||||
Website.objects.all().delete()
|
Website.objects.all().delete()
|
||||||
|
|
||||||
|
|
||||||
class TestDomainApplicationAdminTable(MockEppLib):
|
|
||||||
"""Tests the table for DomainApplicationAdmin"""
|
|
||||||
def setUp(self):
|
|
||||||
"""Enables epplib patching, and creates a fake admin object"""
|
|
||||||
super().setUp()
|
|
||||||
self.site = AdminSite()
|
|
||||||
self.admin = DomainApplicationAdmin(model=DomainApplication, admin_site=self.site)
|
|
||||||
|
|
||||||
def test_table_sorted_alphabetically(self):
|
|
||||||
"""Tests if DomainApplicationAdmin table is sorted alphabetically"""
|
|
||||||
# Creates a list of DomainApplications in scrambled order
|
|
||||||
multiple_unalphabetical_domain_objects("application")
|
|
||||||
|
|
||||||
request = self.factory.get("/")
|
|
||||||
request.user = self.superuser
|
|
||||||
|
|
||||||
# Get the expected list of alphabetically sorted DomainApplications
|
|
||||||
expected_order = DomainApplication.objects.order_by("requested_domain__name")
|
|
||||||
|
|
||||||
# Get the returned queryset
|
|
||||||
queryset = self.admin.get_queryset(request)
|
|
||||||
|
|
||||||
# Check the order
|
|
||||||
self.assertEqual(
|
|
||||||
list(queryset),
|
|
||||||
list(expected_order),
|
|
||||||
)
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
"""Delete all associated domain objects"""
|
|
||||||
super().tearDown()
|
|
||||||
Domain.objects.all().delete()
|
|
||||||
DomainInformation.objects.all().delete()
|
|
||||||
DomainApplication.objects.all().delete()
|
|
||||||
User.objects.all().delete()
|
|
||||||
Contact.objects.all().delete()
|
|
||||||
Website.objects.all().delete()
|
|
||||||
|
|
||||||
|
|
||||||
class DomainInvitationAdminTest(TestCase):
|
class DomainInvitationAdminTest(TestCase):
|
||||||
"""Tests for the DomainInvitation page"""
|
"""Tests for the DomainInvitation page"""
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue