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)