Exemplo n.º 1
0
    def test_bytes_join_attachment(self):
        href_id="http://tempuri.org/1/634133419330914808"
        payload="ANJNSLJNDYBC SFDJNIREMX:CMKSAJN"
        envelope = '''
            <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
                <s:Body>
                    <DownloadPartFileResponse xmlns="http://tempuri.org/">
                        <DownloadPartFileResult xmlns:a="http://schemas.datacontract.org/2004/07/KlanApi.Common"
                                                xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                            <a:ErrorCode>0</a:ErrorCode>
                            <a:ErrorMessage i:nil="true"/>
                            <a:Data>
                                <xop:Include href="cid:%s" xmlns:xop="http://www.w3.org/2004/08/xop/include"/>
                            </a:Data>
                        </DownloadPartFileResult>
                    </DownloadPartFileResponse>
                </s:Body>
            </s:Envelope>
        ''' % quote_plus(href_id)

        (joinedmsg, numreplaces) = _join_attachment(href_id, envelope, payload)

        soaptree = etree.fromstring(joinedmsg)

        body = soaptree.find("{%s}Body" % ns.soap_env)
        response = body.getchildren()[0]
        result = response.getchildren()[0]
        r = XmlDocument().from_element(DownloadPartFileResult, result)

        self.assertEquals(payload, r.Data)
Exemplo n.º 2
0
    def test_bytes_join_attachment(self):
        href_id = "http://tempuri.org/1/634133419330914808"
        payload = "ANJNSLJNDYBC SFDJNIREMX:CMKSAJN"
        envelope = '''
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <DownloadPartFileResponse xmlns="http://tempuri.org/">
      <DownloadPartFileResult
            xmlns:a="http://schemas.datacontract.org/2004/07/KlanApi.Common"
            xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <a:ErrorCode>0</a:ErrorCode>
        <a:ErrorMessage i:nil="true"/>
        <a:Data>
          <xop:Include href="cid:%s"
                             xmlns:xop="http://www.w3.org/2004/08/xop/include"/>
        </a:Data>
      </DownloadPartFileResult>
    </DownloadPartFileResponse>
  </s:Body>
</s:Envelope>
        ''' % href_id

        (joinedmsg, numreplaces) = _join_attachment(NS_SOAP11_ENV, href_id,
                                                    envelope, payload)

        soaptree = etree.fromstring(joinedmsg)

        body = soaptree.find(ns.SOAP11_ENV("Body"))
        response = body.getchildren()[0]
        result = response.getchildren()[0]
        r = XmlDocument().from_element(None, DownloadPartFileResult, result)

        self.assertEqual(payload, r.Data)