コード例 #1
0
 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)
コード例 #2
0
ファイル: response.py プロジェクト: lselinger/pyxcli
    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)
コード例 #3
0
ファイル: response.py プロジェクト: xcnix/pyxcli
    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)
コード例 #4
0
 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)