Skip to content

Commit

Permalink
[PRMDR-873] improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
joefong-nhs committed May 17, 2024
1 parent 7e24e9c commit d725903
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions lambdas/tests/unit/services/test_mock_pds_api_service.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
import json

import pytest
from models.pds_models import PatientDetails
from requests.models import Response
from services.mock_pds_service import MockPdsApiService
from tests.unit.helpers.data.pds.pds_patient_response import PDS_PATIENT

pds_service = MockPdsApiService()


def test_fetch_patient_details_valid_returns_PatientDetails(mocker):
nhs_number = "9000000025"
from utils.exceptions import PatientNotFoundException

response = Response()
response.status_code = 200
response._content = json.dumps(PDS_PATIENT).encode("utf-8")

mocker.patch(
"services.mock_pds_service.MockPdsApiService.pds_request",
return_value=response,
)
def test_fetch_patient_details_valid_returns_PatientDetails():
nhs_number = "9000000002"

pds_service = MockPdsApiService()
actual = pds_service.fetch_patient_details(nhs_number)

expected = PatientDetails(
givenName=["Jane"],
familyName="Smith",
birthDate="2010-10-22",
postalCode="LS1 6AE",
nhsNumber="9000000009",
nhsNumber="9000000002",
superseded=False,
restricted=False,
generalPracticeOds="Y12345",
generalPracticeOds="H81109",
active=True,
)

assert actual == expected


def test_fetch_patient_details_valid_raise_patient_not_found_exception_if_mock_patient_not_exist():
nhs_number = "987654321"

pds_service = MockPdsApiService()
with pytest.raises(PatientNotFoundException):
pds_service.fetch_patient_details(nhs_number)

0 comments on commit d725903

Please sign in to comment.