-
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.
Use fixtures to test extension validation
- Loading branch information
1 parent
77f7572
commit bdd2952
Showing
9 changed files
with
241 additions
and
78 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
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,6 @@ | ||
import pytest | ||
|
||
from fixtures.extensions import ( | ||
raises_phase_plus_detail_error, | ||
raises_phase_duplicate_error, | ||
) |
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,106 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def raises_phase_plus_detail_error(): | ||
def _ext_test(fhir_input, resource): | ||
fhir_input["extension"] = [ | ||
{ | ||
"url": "timingPhaseDetail", | ||
"extension": [ | ||
{ | ||
"url": "timingDetail", | ||
"valueRange": { | ||
"low": {"value": -7, "unit": "days"}, | ||
"high": {"value": 0, "unit": "days"}, | ||
}, | ||
}, | ||
{ | ||
"url": "timingPhase", | ||
"valueCodeableConcept": { | ||
"coding": [ | ||
{ | ||
"system": "http://snomed.info/sct", | ||
"code": "281379000", | ||
"display": "pre-admission", | ||
} | ||
] | ||
}, | ||
}, | ||
], | ||
}, | ||
{ | ||
"url": "timingPhase", | ||
"valueCodeableConcept": { | ||
"coding": [ | ||
{ | ||
"system": "http://snomed.info/sct", | ||
"code": 278307001, | ||
"display": "on admission", | ||
} | ||
] | ||
}, | ||
}, | ||
] | ||
source = fhir_input | ||
with pytest.raises(ValueError, match="cannot appear together"): | ||
resource(**source) | ||
|
||
return _ext_test | ||
|
||
|
||
@pytest.fixture | ||
def raises_phase_duplicate_error(): | ||
def _ext_test(fhir_input, resource): | ||
fhir_input["extension"] = [ | ||
{ | ||
"url": "timingPhaseDetail", | ||
"extension": [ | ||
{ | ||
"url": "timingDetail", | ||
"valueRange": { | ||
"low": {"value": -7, "unit": "days"}, | ||
"high": {"value": 0, "unit": "days"}, | ||
}, | ||
}, | ||
{ | ||
"url": "timingPhase", | ||
"valueCodeableConcept": { | ||
"coding": [ | ||
{ | ||
"system": "http://snomed.info/sct", | ||
"code": "281379000", | ||
"display": "pre-admission", | ||
} | ||
] | ||
}, | ||
}, | ||
], | ||
}, | ||
{ | ||
"url": "timingPhaseDetail", | ||
"extension": [ | ||
{ | ||
"url": "timingPhase", | ||
"valueCodeableConcept": { | ||
"coding": [ | ||
{ | ||
"system": "http://snomed.info/sct", | ||
"code": 278307001, | ||
"display": "on admission", | ||
} | ||
] | ||
}, | ||
}, | ||
{ | ||
"url": "timingDetail", | ||
"valueString": "ever", | ||
}, | ||
], | ||
}, | ||
] | ||
source = fhir_input | ||
with pytest.raises(ValueError, match="can only appear once"): | ||
resource(**source) | ||
|
||
return _ext_test |
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
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
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
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
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
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