def take_action(self, parsed_args): column_headers = ('id', 'uuid', 'name', 'description', 'type', 'virtualization', 'sizes', 'auto_imaging', 'public', 'is_admin', 'active', '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_provider(parsed_args.id) provider = () 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']) provider = (message['id'], message['uuid'], message['name'], message['description'], message['type']['name'], message['virtualization']['name'], ', '.join([ value['name'] for value in message['sizes'] ]), message['auto_imaging'], message['public'], message['is_admin'], message['active'], start_date, end_date) return (column_headers, provider)
def test_getting_provider_when_response_is_ok(self): api = AtmosphereAPI('token', base_url=self.mock_users_base_url) response = api.get_provider(4) assert response.ok assert response.message['id'] == 4 and response.message[ 'name'] == 'Cloudlab - ErikOS'
def test_getting_provider_when_response_is_not_ok(self): api = AtmosphereAPI('token', base_url=self.mock_users_bad_base_url) response = api.get_provider(4) assert not response.ok