Skip to content

Commit 4077ea7

Browse files
committed
Update helper tests to include validation for unsupported resource types (e.g., CustomModel)
Ref: #64
1 parent cfaa438 commit 4077ea7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/test_helpers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
import fhirpy_types_r4b as r4b
33
import pytest
44

5+
class CustomModel:
6+
pass
7+
CUSTOM_MODEL = CustomModel()
58
PATIENT_DATA = {
69
"resourceType": "Patient",
710
"name": [{"given": ["First", "Middle"], "family": "Last"}],
811
}
9-
1012
PATIENT_RESOURCE = r4b.Patient(**PATIENT_DATA)
1113

1214
EXPRESSION = "Patient.name.given"
@@ -30,6 +32,7 @@ def compile_as_test(fn, resource, path, input_type, output_type, expected):
3032
[
3133
(compile_as_first, PATIENT_RESOURCE, EXPRESSION, r4b.Observation, str, "Resource type is <class 'fhirpy_types_r4b.Patient'>, expected <class 'fhirpy_types_r4b.Observation'>"),
3234
(compile_as_array, PATIENT_RESOURCE, EXPRESSION, r4b.Observation, list[str], "Resource type is <class 'fhirpy_types_r4b.Patient'>, expected <class 'fhirpy_types_r4b.Observation'>"),
35+
(compile_as_first, CUSTOM_MODEL, "Patient.name", type(CUSTOM_MODEL), str, "Don't know how to work with type <class 'tests.test_helpers.CustomModel'>"),
3336
],
3437
)
3538
def exception_compile_as_test(fn, resource, path, input_type, output_type, expected):

0 commit comments

Comments
 (0)