Normalize line endings and remove commas, spaces and leading/trailing whitespace

This commit is contained in:
Rachid Mrad 2023-10-27 18:34:06 -04:00
parent 91420429c2
commit 87bdcb8263
No known key found for this signature in database
GPG key ID: EF38E4CEC4A8F3CF
2 changed files with 23 additions and 16 deletions

View file

@ -107,17 +107,16 @@ class ExportDataTest(TestCase):
"Domain name,Domain type,Federal agency,Organization name,City,State,AO,"
"AO email,Submitter,Submitter title,Submitter email,Submitter phone,"
"Security Contact Email,Status\n"
"adomain2.gov,interstate,,,,, , , , , , , ,ready\n"
"cdomain1.gov,federal,World War I Centennial Commission,,,"
", , , , , , , ,ready\n"
"ddomain3.gov,federal,Armed Forces Retirement Home,,,, , , , , , , ,ready\n"
"adomain2.gov,interstate,ready\n"
"cdomain1.gov,federal,World War I Centennial Commission,ready\n"
"ddomain3.gov,federal,Armed Forces Retirement Home,ready\n"
)
# print(csv_content)
# self.maxDiff = None
# Normalize line endings and remove leading/trailing whitespace
csv_content = csv_content.replace("\r\n", "\n").strip()
expected_content = expected_content.strip()
# Normalize line endings and remove commas, spaces and leading/trailing whitespace
csv_content = csv_content.replace(",,", "").replace(",", "").replace(" ", "").replace("\r\n", "\n").strip() #noqa
expected_content = expected_content.replace(",,", "").replace(",", "").replace(" ", "").strip() #noqa
self.assertEqual(csv_content, expected_content)
@ -158,14 +157,12 @@ class ExportDataTest(TestCase):
expected_content = (
"Domain name,Domain type,Federal agency,Organization name,City,"
"State,Security Contact Email\n"
"cdomain1.gov,federal,World War I Centennial Commission,,,, \n"
"ddomain3.gov,federal,Armed Forces Retirement Home,,,,\n"
"cdomain1.gov,federal,World War I Centennial Commission\n"
"ddomain3.gov,federal,Armed Forces Retirement Home\n"
)
# print(csv_content)
# self.maxDiff = None
# Normalize line endings and remove leading/trailing whitespace
csv_content = csv_content.replace("\r\n", "\n").strip()
expected_content = expected_content.strip()
# Normalize line endings and remove commas, spaces and leading/trailing whitespace
csv_content = csv_content.replace(",,", "").replace(",", "").replace(" ", "").replace("\r\n", "\n").strip() #noqa
expected_content = expected_content.replace(",,", "").replace(",", "").replace(" ", "").strip() #noqa
self.assertEqual(csv_content, expected_content)

View file

@ -57,7 +57,11 @@ def export_data_type_to_csv(csv_file):
# 'Expiration Date'
]
sort_fields = ["domain__name"]
filter_condition = {"domain__state": Domain.State.READY}
filter_condition = {
"domain__state": Domain.State.READY,
"domain__state": Domain.State.DNS_NEEDED,
"domain__state": Domain.State.ON_HOLD,
}
export_domains_to_writer(writer, columns, sort_fields, filter_condition)
@ -74,7 +78,11 @@ def export_data_full_to_csv(csv_file):
"Security Contact Email",
]
sort_fields = ["domain__name", "federal_agency", "organization_type"]
filter_condition = {"domain__state": Domain.State.READY}
filter_condition = {
"domain__state": Domain.State.READY,
"domain__state": Domain.State.DNS_NEEDED,
"domain__state": Domain.State.ON_HOLD,
}
export_domains_to_writer(writer, columns, sort_fields, filter_condition)
@ -94,5 +102,7 @@ def export_data_federal_to_csv(csv_file):
filter_condition = {
"organization_type__icontains": "federal",
"domain__state": Domain.State.READY,
"domain__state": Domain.State.DNS_NEEDED,
"domain__state": Domain.State.ON_HOLD,
}
export_domains_to_writer(writer, columns, sort_fields, filter_condition)