-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e24e9c
commit d725903
Showing
1 changed file
with
15 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |