def test_delete_missing_param(self, store: FHIRStore, test_patient): """delete() returns None when no matching document was found""" with raises( BadRequestError, match= "one of: 'instance_id', 'resource_id' or 'source_id' are required", ): store.delete("Patient")
def test_delete_by_source_id(self, store: FHIRStore, test_patient): """delete() finds a document in the database""" store.create(test_patient) source_id = "pyrogSourceId" metadata = { "tag": [ { "system": ARKHN_CODE_SYSTEMS.source, "code": source_id }, { "code": "some-other-tag" }, ] } store.create({ "resourceType": "Patient", "id": "pat2", "meta": metadata }) store.create({ "resourceType": "Patient", "id": "pat3", "meta": metadata }) result = store.delete("Patient", source_id=source_id) assert result == 2
def test_delete_instance(self, store: FHIRStore, test_patient): """delete() finds a document in the database""" store.create(test_patient) result = store.delete("Patient", test_patient["id"]) assert result == 1
def test_delete_resource_not_found(self, store: FHIRStore, test_patient): """delete() returns None when no matching document was found""" with raises(NotFoundError): store.delete("Patient", test_patient["id"])
def test_delete_bad_resource_type(self, store: FHIRStore): """delete() raises if resource type is unknown""" with raises(NotFoundError, match='unsupported FHIR resource: "unknown"'): store.delete("unknown", "864321")