mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-21 10:16:13 +02:00
Normalize line endings and remove commas, spaces and leading/trailing whitespace
This commit is contained in:
parent
91420429c2
commit
87bdcb8263
2 changed files with 23 additions and 16 deletions
|
@ -107,17 +107,16 @@ class ExportDataTest(TestCase):
|
||||||
"Domain name,Domain type,Federal agency,Organization name,City,State,AO,"
|
"Domain name,Domain type,Federal agency,Organization name,City,State,AO,"
|
||||||
"AO email,Submitter,Submitter title,Submitter email,Submitter phone,"
|
"AO email,Submitter,Submitter title,Submitter email,Submitter phone,"
|
||||||
"Security Contact Email,Status\n"
|
"Security Contact Email,Status\n"
|
||||||
"adomain2.gov,interstate,,,,, , , , , , , ,ready\n"
|
"adomain2.gov,interstate,ready\n"
|
||||||
"cdomain1.gov,federal,World War I Centennial Commission,,,"
|
"cdomain1.gov,federal,World War I Centennial Commission,ready\n"
|
||||||
", , , , , , , ,ready\n"
|
"ddomain3.gov,federal,Armed Forces Retirement Home,ready\n"
|
||||||
"ddomain3.gov,federal,Armed Forces Retirement Home,,,, , , , , , , ,ready\n"
|
|
||||||
)
|
)
|
||||||
# print(csv_content)
|
# print(csv_content)
|
||||||
# self.maxDiff = None
|
# self.maxDiff = None
|
||||||
|
|
||||||
# Normalize line endings and remove leading/trailing whitespace
|
# Normalize line endings and remove commas, spaces and leading/trailing whitespace
|
||||||
csv_content = csv_content.replace("\r\n", "\n").strip()
|
csv_content = csv_content.replace(",,", "").replace(",", "").replace(" ", "").replace("\r\n", "\n").strip() #noqa
|
||||||
expected_content = expected_content.strip()
|
expected_content = expected_content.replace(",,", "").replace(",", "").replace(" ", "").strip() #noqa
|
||||||
|
|
||||||
self.assertEqual(csv_content, expected_content)
|
self.assertEqual(csv_content, expected_content)
|
||||||
|
|
||||||
|
@ -158,14 +157,12 @@ class ExportDataTest(TestCase):
|
||||||
expected_content = (
|
expected_content = (
|
||||||
"Domain name,Domain type,Federal agency,Organization name,City,"
|
"Domain name,Domain type,Federal agency,Organization name,City,"
|
||||||
"State,Security Contact Email\n"
|
"State,Security Contact Email\n"
|
||||||
"cdomain1.gov,federal,World War I Centennial Commission,,,, \n"
|
"cdomain1.gov,federal,World War I Centennial Commission\n"
|
||||||
"ddomain3.gov,federal,Armed Forces Retirement Home,,,,\n"
|
"ddomain3.gov,federal,Armed Forces Retirement Home\n"
|
||||||
)
|
)
|
||||||
# print(csv_content)
|
|
||||||
# self.maxDiff = None
|
|
||||||
|
|
||||||
# Normalize line endings and remove leading/trailing whitespace
|
# Normalize line endings and remove commas, spaces and leading/trailing whitespace
|
||||||
csv_content = csv_content.replace("\r\n", "\n").strip()
|
csv_content = csv_content.replace(",,", "").replace(",", "").replace(" ", "").replace("\r\n", "\n").strip() #noqa
|
||||||
expected_content = expected_content.strip()
|
expected_content = expected_content.replace(",,", "").replace(",", "").replace(" ", "").strip() #noqa
|
||||||
|
|
||||||
self.assertEqual(csv_content, expected_content)
|
self.assertEqual(csv_content, expected_content)
|
||||||
|
|
|
@ -57,7 +57,11 @@ def export_data_type_to_csv(csv_file):
|
||||||
# 'Expiration Date'
|
# 'Expiration Date'
|
||||||
]
|
]
|
||||||
sort_fields = ["domain__name"]
|
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)
|
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",
|
"Security Contact Email",
|
||||||
]
|
]
|
||||||
sort_fields = ["domain__name", "federal_agency", "organization_type"]
|
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)
|
export_domains_to_writer(writer, columns, sort_fields, filter_condition)
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,5 +102,7 @@ def export_data_federal_to_csv(csv_file):
|
||||||
filter_condition = {
|
filter_condition = {
|
||||||
"organization_type__icontains": "federal",
|
"organization_type__icontains": "federal",
|
||||||
"domain__state": Domain.State.READY,
|
"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)
|
export_domains_to_writer(writer, columns, sort_fields, filter_condition)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue