def test_search_not_found(self, mock_get_store): """ Calls the search method and handles the case where no result is found. """ resource = Patient(id="test") error = OperationOutcome(id="notfound", issue=[{ "severity": "error", "code": "noop", "diagnostics": "bobo" }]) mock_get_store.return_value.normalize_resource.return_value = resource mock_get_store.return_value.search.return_value = error r = BaseResource(resource=resource) res = r.search(query_string="name=NotFound") assert res == error mock_get_store.return_value.search.assert_called_once_with( "BaseResource", as_json=True, params=None, query_string="name=NotFound") assert r.resource == resource assert r.id == resource.id
def test_search_params(self, mock_get_store): """ Calls the search method of the fhirstore client using `params` """ resource = Patient(id="test") mock_get_store.return_value.normalize_resource.return_value = resource mock_get_store.return_value.search.return_value = resource r = BaseResource(resource=resource) params = MultiDict((("name", "Vincent"), )) res = r.search(params=params) assert res == resource mock_get_store.return_value.search.assert_called_once_with( "BaseResource", as_json=True, params=params, query_string=None) assert r.resource == resource assert r.id == resource.id
def test_search_qs(self, mock_get_store): """ Calls the search method of the fhirstore client using `query_string` """ resource = Patient(id="test") mock_get_store.return_value.normalize_resource.return_value = resource mock_get_store.return_value.search.return_value = resource r = BaseResource(resource=resource) res = r.search(query_string="name=Vincent") assert res == resource mock_get_store.return_value.search.assert_called_once_with( "BaseResource", as_json=True, params=None, query_string="name=Vincent") assert r.resource == resource assert r.id == resource.id