Skip to content

Commit

Permalink
Fix more rebase errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Plowman committed Oct 18, 2023
1 parent 3905f17 commit c008281
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions application/quality_checker/quality_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion application/quality_checker/tests/test_check_dos.py
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
19 changes: 11 additions & 8 deletions application/quality_checker/tests/test_quality_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand All @@ -35,28 +37,29 @@ 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:
# Arrange
# 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),
],
)

0 comments on commit c008281

Please sign in to comment.