Browse Source

Atualizado referencia do signxml temporariamente ao branch da trustcode

até que uma nova versão do signxml seja liberada
Adicionando teste da assinatura do xml
tags/0.1.5
Danimar Ribeiro 9 years ago
parent
commit
17d09339c1
  1. 19
      pytrustnfe/test/XMLs/paulistana_canc_errado.xml
  2. 10
      pytrustnfe/test/XMLs/paulistana_canc_ok.xml
  3. 2
      pytrustnfe/test/test_assinatura.py
  4. 25
      pytrustnfe/test/test_comunicacao.py
  5. 2
      requirements.txt

19
pytrustnfe/test/XMLs/paulistana_canc_errado.xml

@ -1 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?><RetornoCancelamentoNFe xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.prefeitura.sp.gov.br/nfe"><Cabecalho Versao="1" xmlns=""><Sucesso>false</Sucesso></Cabecalho><Erro xmlns=""><Codigo>1305</Codigo><Descricao>Assinatura de cancelamento da NFS-e incorreta.</Descricao><ChaveNFe><InscricaoPrestador>51212382</InscricaoPrestador><NumeroNFe>446</NumeroNFe><CodigoVerificacao>APR9QMJR</CodigoVerificacao></ChaveNFe></Erro></RetornoCancelamentoNFe>
<?xml version="1.0" encoding="UTF-8"?>
<RetornoCancelamentoNFe
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.prefeitura.sp.gov.br/nfe">
<Cabecalho Versao="1" xmlns="">
<Sucesso>false</Sucesso>
</Cabecalho>
<Erro xmlns="">
<Codigo>1305</Codigo>
<Descricao>Assinatura de cancelamento da NFS-e incorreta.</Descricao>
<ChaveNFe>
<InscricaoPrestador>512382</InscricaoPrestador>
<NumeroNFe>446</NumeroNFe>
<CodigoVerificacao>APR9QMJR</CodigoVerificacao>
</ChaveNFe>
</Erro>
</RetornoCancelamentoNFe>

10
pytrustnfe/test/XMLs/paulistana_canc_ok.xml

@ -1 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?><RetornoCancelamentoNFe xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.prefeitura.sp.gov.br/nfe"><Cabecalho Versao="1" xmlns=""><Sucesso>true</Sucesso></Cabecalho></RetornoCancelamentoNFe>
<?xml version="1.0" encoding="UTF-8"?>
<RetornoCancelamentoNFe
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.prefeitura.sp.gov.br/nfe">
<Cabecalho Versao="1" xmlns="">
<Sucesso>true</Sucesso>
</Cabecalho>
</RetornoCancelamentoNFe>

2
pytrustnfe/test/test_assinatura.py

@ -8,7 +8,6 @@ import os
import os.path import os.path
import unittest import unittest
from lxml import etree from lxml import etree
from unittest import skip
from pytrustnfe.nfe.assinatura import Assinatura from pytrustnfe.nfe.assinatura import Assinatura
@ -46,7 +45,6 @@ class test_assinatura(unittest.TestCase):
etree.fromstring(XML_ERRADO), etree.fromstring(XML_ERRADO),
'NFe43150602261542000143550010000000761792265342') 'NFe43150602261542000143550010000000761792265342')
@skip('Pulando')
def test_assinar_xml_valido(self): def test_assinar_xml_valido(self):
pfx = open(os.path.join(self.caminho, 'teste.pfx')).read() pfx = open(os.path.join(self.caminho, 'teste.pfx')).read()
signer = Assinatura(pfx, '123456') signer = Assinatura(pfx, '123456')

25
pytrustnfe/test/test_comunicacao.py

@ -4,11 +4,8 @@ Created on Jun 16, 2015
@author: danimar @author: danimar
''' '''
import mock
import unittest import unittest
from unittest import skip
import os.path import os.path
from pytrustnfe.nfe.comunicacao import executar_consulta
XML_RETORNO = '<retEnviNFe><cStat>103</cStat>' \ XML_RETORNO = '<retEnviNFe><cStat>103</cStat>' \
@ -19,25 +16,5 @@ class test_comunicacao(unittest.TestCase):
caminho = os.path.dirname(__file__) caminho = os.path.dirname(__file__)
@skip('Por enquanto pulamos')
def test_envio_nfe(self): def test_envio_nfe(self):
dir_pfx = os.path.join(self.caminho, 'teste.pfx')
with mock.patch('pytrustnfe.client.requests') as request:
conn = request.return_value
retorno = mock.MagicMock()
type(retorno).status = mock.PropertyMock(return_value='200')
retorno.read.return_value = XML_RETORNO
conn.getresponse.return_value = retorno
xml, objeto = executar_consulta(dir_pfx)
self.assertEqual(
xml, XML_RETORNO,
'Envio de NF-e com problemas - xml de retorno inválido')
self.assertEqual(
objeto.cUF, 42,
'Envio de NF-e com problemas - objeto de retorno inválido')
self.assertEqual(
objeto.cStat, 103,
'Envio de NF-e com problemas - objeto de retorno inválido')
pass

2
requirements.txt

@ -6,7 +6,7 @@ coveralls
http://xmlsoft.org/sources/python/libxml2-python-2.6.21.tar.gz http://xmlsoft.org/sources/python/libxml2-python-2.6.21.tar.gz
https://github.com/odoo-brazil/pyxmlsec/archive/master.zip https://github.com/odoo-brazil/pyxmlsec/archive/master.zip
Jinja2 Jinja2
signxml
https://github.com/Trust-Code/signxml/archive/sign-by-reference.zip
pypandoc pypandoc
suds suds
suds_requests suds_requests

Loading…
Cancel
Save