Skip to content

Commit

Permalink
WIP: modifying new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Filienko committed Dec 13, 2023
1 parent cfb4d90 commit 95084de
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
18 changes: 7 additions & 11 deletions tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def external_patient_search_active(datadir):
def new_patient(datadir):
return load_json(datadir, "new_patient_result.json")

@fixture
def new_patient_active(datadir):
return load_json(datadir, "new_patient_result_active.json")

@fixture
def internal_patient_miss(datadir):
Expand Down Expand Up @@ -85,8 +88,8 @@ def test_new_upsert(
external_patient_search_active,
internal_patient_miss,
new_patient,
internal_patient_inactive_match
):
new_patient_active
):
"""Without finding a matching patient, should insert new and return"""

# Mock HAPI search failing to find a matching patient
Expand All @@ -107,21 +110,14 @@ def test_new_upsert(

"""Finding inactive patient, user specified to not restore, should insert new and return"""

# Mock HAPI search finding an inactive matching patient
mocker.patch(
"patientsearch.models.sync.requests.get",
return_value=mock_response(internal_patient_inactive_match),
)

# Mock POST to generate new patient on HAPI
mocker.patch(
"patientsearch.models.sync.requests.post",
return_value=mock_response(new_patient),
return_value=mock_response(new_patient_active),
)

result = sync_bundle(faux_token, external_patient_search_active)
assert result == new_patient

assert result == new_patient_active


def test_adding_identifier(external_patient_search):
Expand Down
24 changes: 24 additions & 0 deletions tests/test_sync/new_patient_result_active.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"resourceType": "Patient",
"id": "1102",
"meta": {
"versionId": "1",
"lastUpdated": "2020-06-19T12:54:39.363+00:00"
},
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><div class=\"hapiHeaderText\">luke <b>SKYWALKER </b></div><table class=\"hapiPropertyTable\"><tbody><tr><td>Date of birth</td><td><span>12 January 1977</span></td></tr></tbody></table></div>"
},
"active": true,
"name": [
{
"family": "skywalker",
"given": [
"luke"
]
}
],
"gender": "male",
"birthDate": "1977-01-12"
}

0 comments on commit 95084de

Please sign in to comment.