def take_action(self, parsed_args): column_headers = ('uuid', 'name', 'compute_allowed', 'compute_used', 'global_burn_rate', 'start_date') api = AtmosphereAPI(self.app_args.auth_token, base_url=self.app_args.base_url, timeout=self.app_args.api_server_timeout, verify=self.app_args.verify_cert) data = api.get_allocation_sources() allocation_sources = [] if data.ok: for source in data.message['results']: start_date = ts_to_isodate(source['start_date']) allocation_sources.append( (source['uuid'], source['name'], source['compute_allowed'], source['compute_used'], source['global_burn_rate'], start_date)) return (column_headers, tuple(allocation_sources))
def test_getting_allocation_sources_when_response_is_ok(self): api = AtmosphereAPI('token', base_url=self.mock_users_base_url) response = api.get_allocation_sources() assert response.ok assert response.message['results'][0]['id'] == 1 and response.message[ 'results'][0]['name'] == 'eriksf'
def test_getting_allocation_sources_when_response_is_not_ok(self): api = AtmosphereAPI('token', base_url=self.mock_users_bad_base_url) response = api.get_allocation_sources() assert not response.ok