def test_build_response_raises_error_with_correctly_parsed_return(self): for xcli_xml_result in self.XCLI_XML_RESULT_ERROR_CODES_WITH_RETURN: try: self.xcli_client._build_response(fromstring(xcli_xml_result)) self.fail('Should have raised an exception.') except CommandExecutionError as e: self.assertTrue(e.code is not None) self.assertIsInstance(e.return_value, XCLIResponse) self.assertGreater(len(e.return_value.as_list), 0)
def instantiate(cls, cmdroot, encoding): compressed = cmdroot.find("compressed_return") if compressed is not None: text = compressed.attrib["value"] raw = text.decode(encoding).decode("zlib") cmdroot.append(etree.fromstring("<return>%s</return>" % (raw,))) cmdroot.remove(compressed) return cls(cmdroot)
def instantiate(cls, cmdroot, encoding): compressed = cmdroot.find("compressed_return") if compressed is not None: text = compressed.attrib["value"] raw = base64.b64decode(text) raw = (codecs.decode(raw, "zlib")).decode('ascii') cmdroot.append(etree.fromstring("<return>%s</return>" % (raw, ))) cmdroot.remove(compressed) return cls(cmdroot)
def test_build_response_returns_xcli_response_upon_getting_success(self): for xcli_xml_result in self.XCLI_XML_RESULT_SUCCESS_CODES: response = self.xcli_client._build_response( fromstring(xcli_xml_result)) self.assertIsInstance(response, XCLIResponse) self.assertGreater(len(response.as_list), 0)