def test_search(self): instance = self._create_test_data() search.index_entity(instance, index='test_index') result = search.search('test_index', '') assert not result.error assert len(result.items) == 1 results, error, next_page_token = search.to_entities(result) assert len(results) == 1 # with sorting result = search.search('test_index', '', sort='string') assert not result.error assert len(result.items) == 1 result = search.search('test_index', '', sort='-string') assert not result.error assert len(result.items) == 1 result = search.search('test_index', '', sort=search_api.SortExpression('string')) assert not result.error assert len(result.items) == 1 # test error handling with mock.patch('ferris3.search.search_api.Index.search', side_effect=search_api.Error(":(")): result = search.search('test_index', '', sort='-string') assert result.error
def test_search(self): instance = self._create_test_data() search.index_entity(instance, index='test_index') results, error, next_cursor = search.search('test_index', '') assert not error assert len(results) == 1