Ejemplo n.º 1
0
 def test_patch_resource(self, store: FHIRStore, test_patient):
     """patch() finds a document in the database"""
     store.create(test_patient)
     store.patch("Patient", test_patient["id"], {"gender": "other"})
     assert store.read("Patient", test_patient["id"]) == {
         **test_patient, "gender": "other"
     }
Ejemplo n.º 2
0
    def test_patch_resource_not_found(self, store: FHIRStore, test_patient):
        """patch() returns None when no matching document was found"""

        with raises(NotFoundError):
            store.patch("Patient", test_patient["id"], {"name": "Patator"})
Ejemplo n.º 3
0
    def test_patch_bad_resource_schema(self, store: FHIRStore, test_patient):
        """patch() raises if json schema validation failed in mongo"""

        store.create(test_patient)
        with raises(ValidationError):
            store.patch("Patient", test_patient["id"], {"gender": "elephant"})
Ejemplo n.º 4
0
    def test_patch_bad_resource_type(self, store: FHIRStore):
        """patch() raises if resource type is unknown"""

        with raises(NotFoundError,
                    match='unsupported FHIR resource: "unknown"'):
            store.patch("unknown", "864321", {"gender": "other"})