From 020af71574a301206c636923777892307928725e Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 17 Dec 2024 10:50:55 -0800 Subject: [PATCH 1/3] fix census BOM error --- app/aws/s3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/aws/s3.py b/app/aws/s3.py index e0022f20b..07b53d687 100644 --- a/app/aws/s3.py +++ b/app/aws/s3.py @@ -402,7 +402,7 @@ def extract_phones(job): phone_index = 0 for item in first_row: # Note: may contain a BOM and look like \ufeffphone number - if item.lower() in ["phone number", "\\ufeffphone number"]: + if item.lower() in ["phone number", "\\ufeffphone number", "phone number\n"]: break phone_index = phone_index + 1 From c2d822b2883c8de62e8e3522b07d55adaabd38f7 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 17 Dec 2024 10:56:27 -0800 Subject: [PATCH 2/3] add tests --- app/aws/s3.py | 7 ++++++- tests/app/aws/test_s3.py | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/aws/s3.py b/app/aws/s3.py index 07b53d687..d97c421f2 100644 --- a/app/aws/s3.py +++ b/app/aws/s3.py @@ -402,7 +402,12 @@ def extract_phones(job): phone_index = 0 for item in first_row: # Note: may contain a BOM and look like \ufeffphone number - if item.lower() in ["phone number", "\\ufeffphone number", "phone number\n"]: + if item.lower() in [ + "phone number", + "\\ufeffphone number", + "\\ufeffphone number\n", + "phone number\n", + ]: break phone_index = phone_index + 1 diff --git a/tests/app/aws/test_s3.py b/tests/app/aws/test_s3.py index e4a9c1c07..f9baa2fde 100644 --- a/tests/app/aws/test_s3.py +++ b/tests/app/aws/test_s3.py @@ -219,6 +219,16 @@ def test_get_s3_file_makes_correct_call(notify_api, mocker): 2, "5555555552", ), + ( + # simulate file saved with utf8withbom + "\\ufeffPHONE NUMBER\n", + "5555555552", + ), + ( + # simulate file saved without utf8withbom + "\\PHONE NUMBER\n", + "5555555552", + ), ], ) def test_get_phone_number_from_s3( From 1a5e8824482f128fd641778b30dcb3b1b172c317 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 17 Dec 2024 11:02:40 -0800 Subject: [PATCH 3/3] fix tests --- tests/app/aws/test_s3.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/app/aws/test_s3.py b/tests/app/aws/test_s3.py index f9baa2fde..843ce3ba0 100644 --- a/tests/app/aws/test_s3.py +++ b/tests/app/aws/test_s3.py @@ -222,11 +222,15 @@ def test_get_s3_file_makes_correct_call(notify_api, mocker): ( # simulate file saved with utf8withbom "\\ufeffPHONE NUMBER\n", + "eee", + 2, "5555555552", ), ( # simulate file saved without utf8withbom "\\PHONE NUMBER\n", + "eee", + 2, "5555555552", ), ],