diff --git a/ingestion/functions/common/parsing_lib.py b/ingestion/functions/common/parsing_lib.py index c1feecb4f..73375375d 100644 --- a/ingestion/functions/common/parsing_lib.py +++ b/ingestion/functions/common/parsing_lib.py @@ -43,7 +43,6 @@ logger = logging.getLogger(__name__) - try: with (Path(__file__).parent / "geocoding_countries.json").open() as g: GEOCODING_COUNTRIES = json.load(g) diff --git a/ingestion/functions/common/parsing_lib_test.py b/ingestion/functions/common/parsing_lib_test.py index 8c0b316ef..4936cafa1 100644 --- a/ingestion/functions/common/parsing_lib_test.py +++ b/ingestion/functions/common/parsing_lib_test.py @@ -10,6 +10,8 @@ import sys import tempfile import datetime +import logging + from contextlib import redirect_stdout from unittest.mock import MagicMock, patch @@ -488,6 +490,11 @@ def test_write_to_server_records_input_for_failed_batch_upsert_with_validation_e with redirect_stdout(io.StringIO()) as f: + # this handler must be set in here for logger to see the redirected stdout + handler = logging.StreamHandler(stream=sys.stdout) + handler.setLevel(logging.DEBUG) + parsing_lib.logger.addHandler(handler) + numCreated, numUpdated, numError = parsing_lib.write_to_server( iter([_PARSED_CASE]), "env", _SOURCE_ID, _UPLOAD_ID, {},