def test_delete(self, mock_get_store): """Calls the delete method of the fhirstore client""" resource = Patient(id="test") mock_get_store.return_value.normalize_resource.return_value = resource r = BaseResource(resource=resource) r.delete() mock_get_store.return_value.delete.assert_called_once_with( "BaseResource", "test") assert r.resource is None assert r.id is None
def test_delete_missing_id(self, mock_get_store): """Raises an error when the patch data is not provided""" resource = Patient() mock_get_store.return_value.normalize_resource.return_value = resource r = BaseResource(resource=resource) with pytest.raises( BadRequest, match="Resource ID is required to delete it", ): r = r.delete() assert mock_get_store.return_value.update.call_count == 0