def take_action(self, parsed_args): column_headers = ('action', 'description') 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_instance_actions(parsed_args.id) actions = [] if data.ok: for action in data.message: actions.append(( action['name'], action['description'], )) return (column_headers, tuple(actions))
def test_getting_instance_actions_when_response_is_ok(self): api = AtmosphereAPI('token', base_url=self.mock_users_base_url) response = api.get_instance_actions(1) assert response.ok assert response.message[4]['key'] == 'Reboot' and response.message[4]['description'] == 'Reboots an instance when it is in ANY State'
def test_getting_instance_actions_when_response_is_not_ok(self): api = AtmosphereAPI('token', base_url=self.mock_users_bad_base_url) response = api.get_instance_actions(1) assert not response.ok