Skip to content

Commit

Permalink
✨ Issue #28 added tests for github issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
nazrulworld committed Oct 4, 2020
1 parent 8a1f48a commit f5968b9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
35 changes: 35 additions & 0 deletions fhir/resources/tests/test_github_issues.py
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"
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ exclude = '''
| tests/data
)/
'''

[tool.pytest.ini_options]
minversion = "6.0"
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ universal = 1
# Define setup.py command aliases here
test = pytest

[tool:pytest]
collect_ignore = ['setup.py']

[zest.releaser]
create-wheel = yes
register = no
Expand Down

0 comments on commit f5968b9

Please sign in to comment.