def test_search(mock_requests_get): mock_data = ['obj1', 'obj2', 'obj3'] mock_data = initialize_requests_mocker_and_get_mock_data( mock_requests_get, mock_data=mock_data) assert lib.search(MOCK_TOKEN, MOCK_HOST, 'items', 'test123') == mock_data assert [ mock.call('https://pytest.groclient.url/v2/search/items', headers={'authorization': 'Bearer pytest.groclient.token'}, params={'q': 'test123'}, timeout=None) ] == mock_requests_get.call_args_list
def search(self, entity_type, search_terms): """Search for the given search term. Better matches appear first. Parameters ---------- entity_type : { 'metrics', 'items', 'regions', 'sources' } search_terms : string Returns ------- list of dicts Example:: [{'id': 5604}, {'id': 10204}, {'id': 10210}, ....] """ return lib.search(self.access_token, self.api_host, entity_type, search_terms)
def search(self, entity_type, search_terms): return lib.search(self.access_token, self.api_host, entity_type, search_terms)
def test_search(mock_requests_get): mock_data = ['obj1', 'obj2', 'obj3'] mock_data = initialize_requests_mocker_and_get_mock_data(mock_requests_get, mock_data=mock_data) assert lib.search(MOCK_TOKEN, MOCK_HOST, 'items', 'test123') == mock_data