Browse Source

Removendo print - Ajustando encodings

pull/65/head
Danimar Ribeiro 8 years ago
parent
commit
7b31a2f78f
  1. 2
      pytrustnfe/nfe/__init__.py
  2. 3
      pytrustnfe/nfe/comunicacao.py
  3. 1
      pytrustnfe/xml/__init__.py
  4. 1
      tests/test_xml_serializacao.py

2
pytrustnfe/nfe/__init__.py

@ -189,7 +189,7 @@ def _send(certificado, method, sign, **kwargs):
send_raw=send_raw) send_raw=send_raw)
return { return {
'sent_xml': xml_send, 'sent_xml': xml_send,
'received_xml': response,
'received_xml': response.decode(),
'object': obj 'object': obj
} }

3
pytrustnfe/nfe/comunicacao.py

@ -10,7 +10,6 @@ from ..xml import sanitize_response
def _soap_xml(body, cabecalho): def _soap_xml(body, cabecalho):
print(type(body))
xml = '<?xml version="1.0" encoding="utf-8"?>' xml = '<?xml version="1.0" encoding="utf-8"?>'
xml += '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Header>' xml += '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Header>'
xml += '<nfeCabecMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/' + cabecalho.soap_action + '">' xml += '<nfeCabecMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/' + cabecalho.soap_action + '">'
@ -32,4 +31,4 @@ def executar_consulta(certificado, url, cabecalho, xmlEnviar, send_raw=False):
xml = '<?xml version="1.0" encoding="utf-8"?>' + xmlEnviar.rstrip('\n') xml = '<?xml version="1.0" encoding="utf-8"?>' + xmlEnviar.rstrip('\n')
xml_enviar = xml xml_enviar = xml
xml_retorno = client.post_soap(xml_enviar, cabecalho) xml_retorno = client.post_soap(xml_enviar, cabecalho)
return sanitize_response(xml_retorno)
return sanitize_response(xml_retorno.encode())

1
pytrustnfe/xml/__init__.py

@ -46,7 +46,6 @@ def render_xml(path, template_name, remove_empty, **nfe):
def sanitize_response(response): def sanitize_response(response):
print(response)
tree = etree.fromstring(response) tree = etree.fromstring(response)
# Remove namespaces inuteis na resposta # Remove namespaces inuteis na resposta
for elem in tree.getiterator(): for elem in tree.getiterator():

1
tests/test_xml_serializacao.py

@ -29,7 +29,6 @@ class test_xml_serializacao(unittest.TestCase):
path = os.path.join(os.path.dirname(__file__), 'XMLs') path = os.path.join(os.path.dirname(__file__), 'XMLs')
xml_to_clear = open(os.path.join(path, 'jinja_result.xml'), 'r').read() xml_to_clear = open(os.path.join(path, 'jinja_result.xml'), 'r').read()
xml, obj = sanitize_response(xml_to_clear) xml, obj = sanitize_response(xml_to_clear)
print(type(xml))
self.assertEqual(xml, xml_to_clear) self.assertEqual(xml, xml_to_clear)
self.assertEqual(obj.tpAmb, 'oi') self.assertEqual(obj.tpAmb, 'oi')
self.assertEqual(obj.CNPJ, 'ola') self.assertEqual(obj.CNPJ, 'ola')

Loading…
Cancel
Save