def test_get_available(mock_requests_get): mock_data = initialize_requests_mocker_and_get_mock_data(mock_requests_get) # Test data entity_types = ['items', 'metrics', 'regions'] for ent_type in entity_types: assert lib.get_available(MOCK_TOKEN, MOCK_HOST, ent_type) == mock_data['data']
def test_get_available(mock_requests_get): mock_data = initialize_requests_mocker_and_get_mock_data(mock_requests_get) # Test data entity_types = ['items', 'metrics', 'regions'] for ent_type in entity_types: assert lib.get_available(MOCK_TOKEN, MOCK_HOST, ent_type) == mock_data['data'] # Make sure that call now exists in the mock call stack mock_requests_get.assert_has_calls([ mock.call( 'https://pytest.groclient.url/v2/' + ent_type, headers={'authorization': 'Bearer pytest.groclient.token'}, params=None, timeout=None) ])
def get_available(self, entity_type): """List the first 5000 available entities of the given type. Parameters ---------- entity_type : {'metrics', 'items', 'regions'} Returns ------- data : list of dicts Example:: [ { 'id': 0, 'contains': [1, 2, 3], 'name': 'World', 'level': 1}, { 'id': 1, 'contains': [4, 5, 6], 'name': 'Asia', 'level': 2}, ... ] """ return lib.get_available(self.access_token, self.api_host, entity_type)
def get_available(self, entity_type): return lib.get_available(self.access_token, self.api_host, entity_type)