mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-16 17:47:02 +02:00
Add filter + test skeleton
This commit is contained in:
parent
ebafb31f70
commit
46677f4588
2 changed files with 41 additions and 0 deletions
|
@ -356,6 +356,10 @@ class DomainInvitationAdmin(ListHeaderAdmin):
|
||||||
"email",
|
"email",
|
||||||
"domain__name",
|
"domain__name",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Filters
|
||||||
|
list_filter = ("status",)
|
||||||
|
|
||||||
search_help_text = "Search by email or domain."
|
search_help_text = "Search by email or domain."
|
||||||
|
|
||||||
# Mark the FSM field 'status' as readonly
|
# Mark the FSM field 'status' as readonly
|
||||||
|
|
|
@ -8,6 +8,7 @@ from registrar.admin import (
|
||||||
DomainAdmin,
|
DomainAdmin,
|
||||||
DomainApplicationAdmin,
|
DomainApplicationAdmin,
|
||||||
DomainApplicationAdminForm,
|
DomainApplicationAdminForm,
|
||||||
|
DomainInvitationAdmin,
|
||||||
ListHeaderAdmin,
|
ListHeaderAdmin,
|
||||||
MyUserAdmin,
|
MyUserAdmin,
|
||||||
AuditedAdmin,
|
AuditedAdmin,
|
||||||
|
@ -847,6 +848,42 @@ class TestDomainApplicationAdmin(MockEppLib):
|
||||||
User.objects.all().delete()
|
User.objects.all().delete()
|
||||||
|
|
||||||
|
|
||||||
|
class DomainInvitationAdminTest(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.site = AdminSite()
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
self.admin = ListHeaderAdmin(model=DomainInvitationAdmin, admin_site=None)
|
||||||
|
self.client = Client(HTTP_HOST="localhost:8080")
|
||||||
|
self.superuser = create_superuser()
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
# delete any applications too
|
||||||
|
DomainInvitation.objects.all().delete()
|
||||||
|
DomainApplication.objects.all().delete()
|
||||||
|
User.objects.all().delete()
|
||||||
|
|
||||||
|
def test_get_filters(self):
|
||||||
|
# Create a mock request object
|
||||||
|
request = self.factory.get("/admin/yourmodel/")
|
||||||
|
# Set the GET parameters for testing
|
||||||
|
request.GET = {
|
||||||
|
"status": "started",
|
||||||
|
"investigator": "Rachid Mrad",
|
||||||
|
"q": "search_value",
|
||||||
|
}
|
||||||
|
# Call the get_filters method
|
||||||
|
filters = self.admin.get_filters(request)
|
||||||
|
|
||||||
|
# Assert the filters extracted from the request GET
|
||||||
|
self.assertEqual(
|
||||||
|
filters,
|
||||||
|
[
|
||||||
|
{"parameter_name": "status", "parameter_value": "started"},
|
||||||
|
{"parameter_name": "investigator", "parameter_value": "Rachid Mrad"},
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ListHeaderAdminTest(TestCase):
|
class ListHeaderAdminTest(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.site = AdminSite()
|
self.site = AdminSite()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue