def test_serialize_get_console_request_to_xml(self): request_obj = GetConsoleOutput(length=50) xml_serialized_request = request_obj.serialize("xml") expected_xml = ('<?xml version=\'1.0\' encoding=\'UTF-8\'?>' '<os-getConsoleOutput length="50" />') self.assertEqual(xml_serialized_request, expected_xml.replace("\n", " "))
def get_console_output(self, server_id, length, requestslib_kwargs=None): """ @summary: Returns Console Output for a server @param server_id: The id of an existing server @type server_id: String @param length: Number of lines of console output @type length: String @return: Console Output for the server @rtype: Requests.response """ url = '{base_url}/servers/{server_id}/action'.format( base_url=self.url, server_id=server_id) get_console_output_request_object = GetConsoleOutput(length=length) resp = self.request('POST', url, request_entity=get_console_output_request_object, response_entity_type=VncConsoleOutput, requestslib_kwargs=requestslib_kwargs) return resp
def test_serialize_get_console_output_request_to_json(self): request_obj = GetConsoleOutput(length=50) json_serialized_request = request_obj.serialize("json") expected_json = '{"os-getConsoleOutput": {"length": "50"}}' self.assertEqual(json_serialized_request, expected_json)