def take_action(self, parsed_args): column_headers = ('id', 'uuid', 'name', 'renewal_strategy', 'compute_allowed', 'compute_used', 'global_burn_rate', 'user_compute_used', 'user_burn_rate', 'start_date', 'end_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_source(parsed_args.id) allocation_source = () if data.ok: message = data.message start_date = ts_to_isodate(message['start_date']) end_date = '' if message['end_date']: end_date = ts_to_isodate(message['end_date']) allocation_source = (message['id'], message['uuid'], message['name'], message['renewal_strategy'], message['compute_allowed'], message['compute_used'], message['global_burn_rate'], message['user_compute_used'], message['user_burn_rate'], start_date, end_date) return (column_headers, allocation_source)
def test_getting_allocation_source_when_response_is_ok(self): api = AtmosphereAPI('token', base_url=self.mock_users_base_url) response = api.get_allocation_source(1) assert response.ok assert response.message['id'] == 1 and response.message[ 'name'] == 'eriksf'
def test_getting_allocation_source_when_response_is_not_ok(self): api = AtmosphereAPI('token', base_url=self.mock_users_bad_base_url) response = api.get_allocation_source(1) assert not response.ok