mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-24 03:30:50 +02:00
lint
This commit is contained in:
parent
d0f9bf1765
commit
0dc66303bf
1 changed files with 1 additions and 104 deletions
|
@ -905,9 +905,7 @@ class TestDomainApplicationAdmin(MockEppLib):
|
|||
DomainApplication.ApplicationStatus.REJECTED,
|
||||
DomainApplication.RejectionReasons.OTHER,
|
||||
)
|
||||
self.assert_email_is_accurate(
|
||||
"Choosing a .gov domain name", 0, EMAIL
|
||||
)
|
||||
self.assert_email_is_accurate("Choosing a .gov domain name", 0, EMAIL)
|
||||
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
|
||||
|
||||
# Approve
|
||||
|
@ -2065,107 +2063,6 @@ class AuditedAdminTest(TestCase):
|
|||
"{} is not ordered alphabetically".format(field.name),
|
||||
)
|
||||
|
||||
def test_alphabetically_sorted_fk_fields_domain_information(self):
|
||||
tested_fields = [
|
||||
DomainInformation.authorizing_official.field,
|
||||
DomainInformation.submitter.field,
|
||||
# DomainInformation.creator.field,
|
||||
(DomainInformation.domain.field, ["name"]),
|
||||
(DomainInformation.domain_application.field, ["requested_domain__name"]),
|
||||
]
|
||||
# Creates multiple domain applications - review status does not matter
|
||||
applications = multiple_unalphabetical_domain_objects("information")
|
||||
|
||||
# Create a mock request
|
||||
request = self.factory.post("/admin/registrar/domaininformation/{}/change/".format(applications[0].pk))
|
||||
|
||||
model_admin = AuditedAdmin(DomainInformation, self.site)
|
||||
|
||||
sorted_fields = []
|
||||
# Typically we wouldn't want two nested for fields,
|
||||
# but both fields are of a fixed length.
|
||||
# For test case purposes, this should be performant.
|
||||
for field in tested_fields:
|
||||
isOtherOrderfield: bool = isinstance(field, tuple)
|
||||
field_obj = None
|
||||
if isOtherOrderfield:
|
||||
sorted_fields = field[1]
|
||||
field_obj = field[0]
|
||||
else:
|
||||
sorted_fields = ["first_name", "last_name"]
|
||||
field_obj = field
|
||||
# We want both of these to be lists, as it is richer test wise.
|
||||
desired_order = self.order_by_desired_field_helper(model_admin, request, field_obj.name, *sorted_fields)
|
||||
current_sort_order = list(model_admin.formfield_for_foreignkey(field_obj, request).queryset)
|
||||
|
||||
# Conforms to the same object structure as desired_order
|
||||
current_sort_order_coerced_type = []
|
||||
|
||||
# This is necessary as .queryset and get_queryset
|
||||
# return lists of different types/structures.
|
||||
# We need to parse this data and coerce them into the same type.
|
||||
for obj in current_sort_order:
|
||||
last = None
|
||||
if not isOtherOrderfield:
|
||||
first = obj.first_name
|
||||
last = obj.last_name
|
||||
elif field_obj == DomainInformation.domain.field:
|
||||
first = obj.name
|
||||
elif field_obj == DomainInformation.domain_application.field:
|
||||
first = obj.requested_domain.name
|
||||
|
||||
name_tuple = self.coerced_fk_field_helper(first, last, field_obj.name, ":")
|
||||
if name_tuple is not None:
|
||||
current_sort_order_coerced_type.append(name_tuple)
|
||||
|
||||
self.assertEqual(
|
||||
desired_order,
|
||||
current_sort_order_coerced_type,
|
||||
"{} is not ordered alphabetically".format(field_obj.name),
|
||||
)
|
||||
|
||||
def test_alphabetically_sorted_fk_fields_domain_invitation(self):
|
||||
tested_fields = [DomainInvitation.domain.field]
|
||||
|
||||
# Creates multiple domain applications - review status does not matter
|
||||
applications = multiple_unalphabetical_domain_objects("invitation")
|
||||
|
||||
# Create a mock request
|
||||
request = self.factory.post("/admin/registrar/domaininvitation/{}/change/".format(applications[0].pk))
|
||||
|
||||
model_admin = AuditedAdmin(DomainInvitation, self.site)
|
||||
|
||||
sorted_fields = []
|
||||
# Typically we wouldn't want two nested for fields,
|
||||
# but both fields are of a fixed length.
|
||||
# For test case purposes, this should be performant.
|
||||
for field in tested_fields:
|
||||
sorted_fields = ["name"]
|
||||
# We want both of these to be lists, as it is richer test wise.
|
||||
|
||||
desired_order = self.order_by_desired_field_helper(model_admin, request, field.name, *sorted_fields)
|
||||
current_sort_order = list(model_admin.formfield_for_foreignkey(field, request).queryset)
|
||||
|
||||
# Conforms to the same object structure as desired_order
|
||||
current_sort_order_coerced_type = []
|
||||
|
||||
# This is necessary as .queryset and get_queryset
|
||||
# return lists of different types/structures.
|
||||
# We need to parse this data and coerce them into the same type.
|
||||
for contact in current_sort_order:
|
||||
first = contact.name
|
||||
last = None
|
||||
|
||||
name_tuple = self.coerced_fk_field_helper(first, last, field.name, ":")
|
||||
if name_tuple is not None:
|
||||
current_sort_order_coerced_type.append(name_tuple)
|
||||
|
||||
self.assertEqual(
|
||||
desired_order,
|
||||
current_sort_order_coerced_type,
|
||||
"{} is not ordered alphabetically".format(field.name),
|
||||
)
|
||||
|
||||
def coerced_fk_field_helper(self, first_name, last_name, field_name, queryset_shorthand):
|
||||
"""Handles edge cases for test cases"""
|
||||
if first_name is None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue