diff --git a/application/quality_checker/quality_checker.py b/application/quality_checker/quality_checker.py index 451f965bf..cff33e50b 100644 --- a/application/quality_checker/quality_checker.py +++ b/application/quality_checker/quality_checker.py @@ -12,7 +12,7 @@ check_pharmacy_profiling, ) from common.commissioned_service_type import BLOOD_PRESSURE, CONTRACEPTION, PALLIATIVE_CARE -from common.dos_db_connection import connect_to_dos_db_replica +from common.dos_db_connection import connect_to_db_reader from common.middlewares import unhandled_exception_logging logger = Logger() @@ -37,7 +37,7 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> None: # def check_dos_data_quality() -> None: """Check the data quality of the dos database.""" - with connect_to_dos_db_replica() as db_connection: + with connect_to_db_reader() as db_connection: # Checks matched odscode services for pharmacy profiling check_pharmacy_profiling(db_connection) diff --git a/application/quality_checker/tests/test_check_dos.py b/application/quality_checker/tests/test_check_dos.py index 3d0ff9b4e..1354bf271 100644 --- a/application/quality_checker/tests/test_check_dos.py +++ b/application/quality_checker/tests/test_check_dos.py @@ -1,11 +1,11 @@ from unittest.mock import MagicMock, call, patch -from application.common.commissioned_service_type import BLOOD_PRESSURE, CONTRACEPTION from application.quality_checker.check_dos import ( check_for_multiple_of_service_type, check_incorrect_zcode_profiling, check_pharmacy_profiling, ) +from common.commissioned_service_type import BLOOD_PRESSURE, CONTRACEPTION FILE_PATH = "application.quality_checker.check_dos" diff --git a/application/quality_checker/tests/test_quality_checker.py b/application/quality_checker/tests/test_quality_checker.py index 02385bda7..496a0721a 100644 --- a/application/quality_checker/tests/test_quality_checker.py +++ b/application/quality_checker/tests/test_quality_checker.py @@ -4,8 +4,8 @@ import pytest from aws_lambda_powertools.utilities.typing import LambdaContext -from application.common.commissioned_service_type import BLOOD_PRESSURE, CONTRACEPTION, PALLIATIVE_CARE from application.quality_checker.quality_checker import check_dos_data_quality, lambda_handler +from common.commissioned_service_type import BLOOD_PRESSURE, CONTRACEPTION, PALLIATIVE_CARE FILE_PATH = "application.quality_checker.quality_checker" @@ -24,9 +24,11 @@ class LambdaContext: return LambdaContext() +@patch(f"{FILE_PATH}.send_finished_metric") @patch(f"{FILE_PATH}.check_dos_data_quality") def test_lambda_handler( mock_check_dos_data_quality: MagicMock, + mock_send_finished_metric: MagicMock, lambda_context: LambdaContext, ) -> None: # Arrange @@ -35,13 +37,14 @@ def test_lambda_handler( lambda_handler(event, lambda_context) # Assert mock_check_dos_data_quality.assert_called_once_with() + mock_send_finished_metric.assert_called_once_with() @patch(f"{FILE_PATH}.check_incorrect_zcode_profiling") @patch(f"{FILE_PATH}.check_pharmacy_profiling") -@patch(f"{FILE_PATH}.connect_to_dos_db_replica") +@patch(f"{FILE_PATH}.connect_to_db_reader") def test_check_dos_data_quality( - mock_connect_to_dos_db_replica: MagicMock, + mock_connect_to_db_reader: MagicMock, mock_check_pharmacy_profiling: MagicMock, mock_check_incorrect_zcode_profiling: MagicMock, ) -> None: @@ -49,14 +52,14 @@ def test_check_dos_data_quality( # Act check_dos_data_quality() # Assert - mock_connect_to_dos_db_replica.assert_called_once_with() + mock_connect_to_db_reader.assert_called_once_with() mock_check_pharmacy_profiling.assert_called_once_with( - mock_connect_to_dos_db_replica().__enter__(), + mock_connect_to_db_reader().__enter__(), ) mock_check_incorrect_zcode_profiling.assert_has_calls( calls=[ - call(mock_connect_to_dos_db_replica().__enter__(), PALLIATIVE_CARE), - call(mock_connect_to_dos_db_replica().__enter__(), BLOOD_PRESSURE), - call(mock_connect_to_dos_db_replica().__enter__(), CONTRACEPTION), + call(mock_connect_to_db_reader().__enter__(), PALLIATIVE_CARE), + call(mock_connect_to_db_reader().__enter__(), BLOOD_PRESSURE), + call(mock_connect_to_db_reader().__enter__(), CONTRACEPTION), ], )