-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Issue #28 added tests for github issues.
- Loading branch information
1 parent
8a1f48a
commit f5968b9
Showing
3 changed files
with
38 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
def test_issue_28(): | ||
"""Running the following code: | ||
from fhir.resources import construct_fhir_element | ||
d = {'resourceType': 'Patient', 'contained':[{'resourceType': 'Patient'}]} | ||
construct_fhir_element('Patient', d) | ||
end up changing the value of d to {'resourceType': 'Patient', 'contained': [{}]} | ||
I would expect it to not change the given object. Moreover, because it doesn't | ||
delete resourceType from the outter dictionary, I assume this behavior is not expected. | ||
Is it on purpose? | ||
Thanks, | ||
Itay""" | ||
from fhir.resources import construct_fhir_element | ||
|
||
pat = construct_fhir_element( | ||
"Patient", | ||
{"resourceType": "Patient", "contained": [{"resourceType": "Patient"}]}, | ||
) | ||
assert pat.contained[0].__class__ == pat.__class__ | ||
assert pat.contained[0].resource_type == "Patient" | ||
assert pat.resource_type == "Patient" | ||
|
||
from fhir.resources.patient import Patient | ||
|
||
pat = Patient(resourceType="Patient", contained=[{"resourceType": "Patient"}]) | ||
assert pat.contained[0].__class__ == pat.__class__ | ||
assert pat.contained[0].resource_type == "Patient" | ||
assert pat.resource_type == "Patient" | ||
|
||
pat = Patient.parse_obj( | ||
{"resourceType": "Patient", "contained": [{"resourceType": "Patient"}]} | ||
) | ||
assert pat.contained[0].__class__ == pat.__class__ | ||
assert pat.contained[0].resource_type == "Patient" | ||
assert pat.resource_type == "Patient" |
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 |
---|---|---|
|
@@ -23,3 +23,6 @@ exclude = ''' | |
| tests/data | ||
)/ | ||
''' | ||
|
||
[tool.pytest.ini_options] | ||
minversion = "6.0" |
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