Black formatting

This commit is contained in:
zandercymatics 2023-12-19 14:18:38 -07:00
parent d539740ae6
commit 12b2f93cb1
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
2 changed files with 39 additions and 29 deletions

View file

@ -92,14 +92,16 @@ def less_console_noise(output_stream=None):
# we opened output_stream so we have to close it
output_stream.close()
class GenericTestHelper(TestCase):
"""A helper class that contains various helper functions for TestCases"""
def __init__(self, admin, model=None, url=None, user=None, factory=None, **kwargs):
"""
Parameters:
admin (ModelAdmin): The Django ModelAdmin instance associated with the model.
model (django.db.models.Model, optional): The Django model associated with the admin page.
url (str, optional): The URL of the Django Admin page to test.
model (django.db.models.Model, optional): The Django model associated with the admin page.
url (str, optional): The URL of the Django Admin page to test.
user (User, optional): The Django User who is making the request.
factory (RequestFactory, optional): An instance of Django's RequestFactory.
"""
@ -109,7 +111,7 @@ class GenericTestHelper(TestCase):
self.admin = admin
self.model = model
self.url = url
def assert_table_sorted(self, o_index, sort_fields):
"""
This helper function validates the sorting functionality of a Django Admin table view.

View file

@ -330,14 +330,14 @@ class TestDomainApplicationAdmin(MockEppLib):
user=self.superuser,
admin=self.admin,
url="/admin/registrar/DomainApplication/",
model=DomainApplication
model=DomainApplication,
)
def test_domain_sortable(self):
"""Tests if the DomainApplication sorts by domain correctly"""
p = "adminpass"
self.client.login(username="superuser", password=p)
multiple_unalphabetical_domain_objects("application")
# Assert that our sort works correctly
@ -359,16 +359,22 @@ class TestDomainApplicationAdmin(MockEppLib):
new_user.save()
# Assert that our sort works correctly
self.test_helper.assert_table_sorted("5", (
"submitter__first_name",
"submitter__last_name",
))
self.test_helper.assert_table_sorted(
"5",
(
"submitter__first_name",
"submitter__last_name",
),
)
# Assert that sorting in reverse works correctly
self.test_helper.assert_table_sorted("-5", (
"-submitter__first_name",
"-submitter__last_name",
))
self.test_helper.assert_table_sorted(
"-5",
(
"-submitter__first_name",
"-submitter__last_name",
),
)
def test_investigator_sortable(self):
"""Tests if the DomainApplication sorts by domain correctly"""
@ -382,16 +388,22 @@ class TestDomainApplicationAdmin(MockEppLib):
new_user.save()
# Assert that our sort works correctly
self.test_helper.assert_table_sorted("6", (
"investigator__first_name",
"investigator__last_name",
))
self.test_helper.assert_table_sorted(
"6",
(
"investigator__first_name",
"investigator__last_name",
),
)
# Assert that sorting in reverse works correctly
self.test_helper.assert_table_sorted("-6", (
"-investigator__first_name",
"-investigator__last_name",
))
self.test_helper.assert_table_sorted(
"-6",
(
"-investigator__first_name",
"-investigator__last_name",
),
)
def test_short_org_name_in_applications_list(self):
"""
@ -975,7 +987,7 @@ class DomainInformationAdminTest(TestCase):
user=self.superuser,
admin=self.admin,
url="/admin/registrar/DomainInformation/",
model=DomainInformation
model=DomainInformation,
)
# Create fake DomainInformation objects
@ -1017,14 +1029,10 @@ class DomainInformationAdminTest(TestCase):
self.client.login(username="superuser", password=p)
# Assert that our sort works correctly
self.test_helper.assert_table_sorted(
"1", ("domain__name",)
)
self.test_helper.assert_table_sorted("1", ("domain__name",))
# Assert that sorting in reverse works correctly
self.test_helper.assert_table_sorted(
"-1", ("-domain__name",)
)
self.test_helper.assert_table_sorted("-1", ("-domain__name",))
def test_submitter_sortable(self):
"""Tests if DomainInformation sorts by submitter correctly"""
@ -1054,7 +1062,7 @@ class UserDomainRoleAdminTest(TestCase):
user=self.superuser,
admin=self.admin,
url="/admin/registrar/UserDomainRole/",
model=UserDomainRole
model=UserDomainRole,
)
def tearDown(self):