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" }
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"})
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"})
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"})