From 0460dcb519396b6b51bf73c2fea2694e0d768035 Mon Sep 17 00:00:00 2001 From: Danimar Ribeiro Date: Tue, 10 May 2016 00:46:30 -0300 Subject: [PATCH] Tests for sending the xml --- pytrustnfe/servicos/assinatura.py | 8 ++------ pytrustnfe/servicos/nfe_autorizacao.py | 8 +++++++- pytrustnfe/xml/nfeEnv.xml | 1 + 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pytrustnfe/servicos/assinatura.py b/pytrustnfe/servicos/assinatura.py index a42adab..6a0a0a6 100644 --- a/pytrustnfe/servicos/assinatura.py +++ b/pytrustnfe/servicos/assinatura.py @@ -35,12 +35,8 @@ def assinar(xml, cert, key, reference): if recursively_empty(elem): parent.remove(elem) - element = xml.find('{' + xml.nsmap[None] + '}NFe') - not_signed = etree.tostring(element) - not_signed = "]>" + \ - not_signed - - signer = xmldsig(element, digest_algorithm=u'sha1') + # element = xml.find('{' + xml.nsmap[None] + '}NFe') + signer = xmldsig(xml, digest_algorithm=u'sha1') ns = {} ns[None] = signer.namespaces['ds'] signer.namespaces = ns diff --git a/pytrustnfe/servicos/nfe_autorizacao.py b/pytrustnfe/servicos/nfe_autorizacao.py index dfc95b4..700a5c2 100644 --- a/pytrustnfe/servicos/nfe_autorizacao.py +++ b/pytrustnfe/servicos/nfe_autorizacao.py @@ -6,6 +6,8 @@ Created on 21/06/2015 ''' from lxml import etree from suds.sax.element import Element +from suds.sax.text import Raw +from suds.sax.parser import Parser from pytrustnfe.servicos.comunicacao import Comunicacao from pytrustnfe import utils from pytrustnfe.xml import render_xml @@ -31,7 +33,11 @@ class NfeAutorizacao(Comunicacao): cabecalho.versaoDados = '3.10' client.set_options(soapheaders=cabecalho) - resposta = client.service.nfeAutorizacaoLote(xml_signed) + p = Parser() + import ipdb; ipdb.set_trace() + resposta = client.service.nfeAutorizacaoLote( + p.parse(string=xml_signed).root()) + print client.last_sent() print client.last_received() diff --git a/pytrustnfe/xml/nfeEnv.xml b/pytrustnfe/xml/nfeEnv.xml index 01e137f..e1a21e2 100644 --- a/pytrustnfe/xml/nfeEnv.xml +++ b/pytrustnfe/xml/nfeEnv.xml @@ -169,6 +169,7 @@ {{ NFe.infNFe.infAdic.infCpl }} + {% endfor %}