Use normal request where possible

This commit is contained in:
zandercymatics 2024-06-06 13:34:09 -06:00
parent 551e85ed22
commit 3fe1f7bfd1
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
2 changed files with 87 additions and 100 deletions

View file

@ -12,7 +12,7 @@ from registrar.utility.csv_export import (
write_csv_for_domains,
get_default_start_date,
get_default_end_date,
write_csv_for_requests,
DomainRequestExport,
)
from django.core.management import call_command
@ -668,8 +668,8 @@ class ExportDataTest(MockDb, MockEppLib):
# We'll skip submission date because it's dynamic and therefore
# impossible to set in expected_content
columns = [
"Requested domain",
"Organization type",
"Domain request",
"Domain type",
]
sort_fields = [
"requested_domain__name",
@ -679,7 +679,15 @@ class ExportDataTest(MockDb, MockEppLib):
"submission_date__lte": self.end_date,
"submission_date__gte": self.start_date,
}
write_csv_for_requests(writer, columns, sort_fields, filter_condition, should_write_header=True)
all_requests = DomainRequest.objects.filter(**filter_condition).order_by(*sort_fields).distinct()
all_requests_dict = all_requests.values(
"requested_domain_name",
"generic_org_type",
"federal_type",
"submission_date"
)
DomainRequestExport.write_csv_for_requests(writer, columns, requests=all_requests_dict, should_write_header=True)
# Reset the CSV file's position to the beginning
csv_file.seek(0)
# Read the content into a variable
@ -687,7 +695,7 @@ class ExportDataTest(MockDb, MockEppLib):
# We expect READY domains first, created between today-2 and today+2, sorted by created_at then name
# and DELETED domains deleted between today-2 and today+2, sorted by deleted then name
expected_content = (
"Requested domain,Organization type\n"
"Domain request,Domain type\n"
"city3.gov,Federal - Executive\n"
"city4.gov,Federal - Executive\n"
)