Update tests + linter

This commit is contained in:
zandercymatics 2023-11-27 08:02:58 -07:00
parent 377786cccf
commit e314a5ff77
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
2 changed files with 16 additions and 9 deletions

View file

@ -343,6 +343,7 @@ class UserDomainRoleAdmin(ListHeaderAdmin):
class DomainInvitationAdmin(ListHeaderAdmin):
"""Custom domain invitation admin class."""
class Meta:
model = models.DomainInvitation
fields = "__all__"

View file

@ -849,26 +849,25 @@ class TestDomainApplicationAdmin(MockEppLib):
class DomainInvitationAdminTest(TestCase):
"""Tests for the DomainInvitation page"""
def setUp(self):
"""Create a client object"""
self.client = Client(HTTP_HOST="localhost:8080")
self.factory = RequestFactory()
self.admin = ListHeaderAdmin(model=DomainInvitationAdmin, admin_site=AdminSite())
self.client = Client(HTTP_HOST="localhost:8080")
self.superuser = create_superuser()
def tearDown(self):
# delete any applications too
"""Delete all DomainInvitation objects"""
DomainInvitation.objects.all().delete()
DomainApplication.objects.all().delete()
User.objects.all().delete()
def test_get_filters(self):
"""Ensures that our filters are displaying correctly"""
# Have to get creative to get past linter
p = "adminpass"
self.client.login(username="superuser", password=p)
# Mock a user
user = mock_user()
response = self.client.get(
"/admin/registrar/domaininvitation/",
{},
@ -879,6 +878,13 @@ class DomainInvitationAdminTest(TestCase):
self.assertContains(response, "invited", count=4)
self.assertContains(response, "retrieved", count=4)
# Check for the HTML context specificially
invited_html = '<a href="?status__exact=invited">invited</a>'
retrieved_html = '<a href="?status__exact=retrieved">retrieved</a>'
self.assertContains(response, invited_html, count=1)
self.assertContains(response, retrieved_html, count=1)
class ListHeaderAdminTest(TestCase):
def setUp(self):