diff --git a/README.md b/README.md index d56e984..bca463f 100644 --- a/README.md +++ b/README.md @@ -23,12 +23,12 @@ Emissão de NFCe Compatibilidade [python 2 e 3](https://github.com/danimaribeiro/PyTrustNFe/pull/6) Implementar novos provedores de NFSe -* [Betha](nfse/cidades/beta.md) - 81 cidades atendidas WIP -* [GINFES](nfse/cidades/ginfes.md) - 79 cidades atendidas -* [WebISS](nfse/cidades/webiss.md) - 51 cidades atendidas -* [ISSIntel](nfse/cidades/issintel.md) - 32 cidades atendidas -* [ISSNET](nfse/cidades/issnet.md) - 32 cidades atendidas -* [Saatri](nfse/cidades/saatri.md) - 31 cidades atendidas +* [Betha](cidades/betha.md) - 81 cidades atendidas WIP +* [GINFES](cidades/ginfes.md) - 79 cidades atendidas +* [WebISS](cidades/webiss.md) - 51 cidades atendidas +* [ISSIntel](cidades/issintel.md) - 32 cidades atendidas +* [ISSNET](cidades/issnet.md) - 32 cidades atendidas +* [Saatri](cidades/saatri.md) - 31 cidades atendidas Exemplos de uso da NFe diff --git a/cidades/betha.md b/cidades/betha.md new file mode 100644 index 0000000..8c5607b --- /dev/null +++ b/cidades/betha.md @@ -0,0 +1,53 @@ +* Água Boa - MT +* Alfenas - MG +* Almirante Tamandaré - PR +* Barracão - PR +* Braço do Norte - SC +* Bento Gonçalves - RS +* Bombinhas - SC +* Capão da Canoa - RS +* Capinzal - SC +* Catanduvas - SC +* Chapecó - SC +* Cocal do Sul - SC +* Congonhas - MG +* Cornélio Procópio - PR +* Criciúma - SC +* Dionísio Cerqueira - SC +* Imbituba - SC +* Garopaba - SC +* General Carneiro - PR +* Goioerê - PR +* Fazenda Rio Grande - PR +* Juti - MS +* Joaçaba - SC +* Itapiranga - SC +* Itaú de Minas - MG +* Lages - SC +* Laguna - SC +* Mandaguaçu - PR +* Mandirituba - PR +* Maravilha - SC +* Mariana - MG +* Mococa - SP +* Morro da Fumaça - SC +* Navegantes - SC +* Nova Andradina - MS +* Orlândia - SP +* Orleans - SC +* Paranavaí - PR +* Pinhalzinho - SC +* Santa Rosa de Viterbo - SP +* Santo Amaro da Imperatriz - SC. +* São Joaquim - SC +* São José - SC +* São Mateus do Sul - PR +* São Miguel do Oeste - SC +* Sombrio - SC +* Tijucas - SC +* Torres - RS +* União da Vitória - PR +* Urussanga - SC +* Várzea Grande - MT +* Xanxerê - SC +* Xaxim - SC diff --git a/cidades/ginfes.md b/cidades/ginfes.md new file mode 100644 index 0000000..cf8e0ce --- /dev/null +++ b/cidades/ginfes.md @@ -0,0 +1,62 @@ +* Amparo - SP +* Arapiraca - AL +* Araraquara - SP +* Araxá - MG +* Belford Roxo - RJ +* Betim - MG +* Caraguatatuba - SP +* Caruaru - PE +* Capivari - SP +* Cataguases - MG +* Cotia - SP +* Diadema - SP +* Eusébio - CE +* Fortaleza - CE +* Franca - SP +* Guaíba - RS +* Guaratinguetá - SP +* Guarujá - SP +* Guarulhos - SP +* Hortolândia - SP +* Itaboraí - RJ +* Itabira - MG +* Itajuba - MG +* Itaúna - MG +* Itu - SP +* Jaboticabal - SP +* Jardinópolis - SP +* Jaú - SP +* Jundiaí - SP +* Lagoa Santa - MG +* Maceió - AL +* Manaus - AM +* Morro Agudo - SP +* Mauá - SP +* Muriaé - MG +* Olímpia - SP +* Paulínia - SP +* Pelotas - RS +* Poços de Caldas - MG +* Porto Ferreira - SP +* Pouso Alegre - MG +* Ribeirão das Neves - MG +* Ribeirão Pires - SP +* Ribeirão Preto - SP +* Rio Claro - SP +* Salto - SP +* Santa Rita do Passa Quatro - SP +* Santo André - SP +* Santos - SP +* São Bernardo do Campo - SP +* São Caetano do Sul - SP +* São Carlos - SP +* São José do Rio Preto - SP +* São José dos Campos - SP +* São Roque - SP +* Sarzedo - MG +* Suzano - SP +* Taquaritinga - SP +* Ubá - MG +* Ubatuba - SP +* Umuarama - PR +* Votuporanga - SP diff --git a/cidades/issintel.md b/cidades/issintel.md new file mode 100644 index 0000000..e69de29 diff --git a/cidades/issnet.md b/cidades/issnet.md new file mode 100644 index 0000000..e69de29 diff --git a/cidades/saatri.md b/cidades/saatri.md new file mode 100644 index 0000000..dbea57f --- /dev/null +++ b/cidades/saatri.md @@ -0,0 +1,8 @@ +* Barreiras - BA +* Boa Vista - RR +* Bom Jesus da Lapa - BA +* Catu - BA +* Eunápolis - BA +* Ipiaú - BA +* Jacobina - BA +* São Sebastião de Passé - BA diff --git a/cidades/webiss.md b/cidades/webiss.md new file mode 100644 index 0000000..4c25ac1 --- /dev/null +++ b/cidades/webiss.md @@ -0,0 +1,32 @@ +* Aracajú - SE +* Arcos - MG +* Bagé - RS +* Barbacena - MG +* Brumado - BA. +* Campo Belo - MG +* Candeias - BA +* Cássia - MG +* Caldas Novas - GO +* Coronel Fabriciano - MG +* Estância - SE +* Extrema - MG +* Feira de Santana–BA +* Formiga - MG +* Guanambi - BA +* Itabuna - BA +* Itapetinga - BA +* Lagarto - SE +* Lucas do Rio Verde - MT +* Luís Eduardo Magalhães - BA +* Niterói - RJ +* Nova Serrana - MG +* Palmas - TO +* Passos - MG +* Porto Nacional - TO +* Santa Rita do Sapucai - MG +* São Gotardo - MG +* São Lourenço - MG +* Tangará da Serra - MT +* Teresópolis - RJ +* Uberaba-MG +* Vitória da Conquista - BA diff --git a/pytrustnfe/nfe/templates/NfeAutorizacao.xml b/pytrustnfe/nfe/templates/NfeAutorizacao.xml index 8cd1fd2..61cfa67 100644 --- a/pytrustnfe/nfe/templates/NfeAutorizacao.xml +++ b/pytrustnfe/nfe/templates/NfeAutorizacao.xml @@ -16,7 +16,7 @@ {{ ide.dhEmi }} {{ ide.dhSaiEnt }} {{ ide.tpNF }} - {{ ide.idDest }} + {{ ide.idDest }} {{ ide.cMunFG }} {{ ide.tpImp }} {{ ide.tpEmis }} @@ -97,7 +97,7 @@ {{ emit.CRT }} {% endwith %} - {% if dest is defined %} + {% if NFe.infNFe.dest is defined %} {% with dest = NFe.infNFe.dest %} {% if dest.tipo == 'person' -%} @@ -125,8 +125,8 @@ {{ dest.IM }} {{ dest.email }} {% endwith %} - - {% endif %} + + {% endif %} {% if NFe.infNFe.retirada is defined %} {{ NFe.infNFe.retirada.CNPJ }} diff --git a/pytrustnfe/nfse/betha/__init__.py b/pytrustnfe/nfse/betha/__init__.py new file mode 100644 index 0000000..f2517fa --- /dev/null +++ b/pytrustnfe/nfse/betha/__init__.py @@ -0,0 +1,113 @@ +# -*- coding: utf-8 -*- +# © 2016 Danimar Ribeiro, Trustcode +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +import os +import suds +from OpenSSL import crypto +from base64 import b64encode +from pytrustnfe.xml import render_xml, sanitize_response +from pytrustnfe.client import get_authenticated_client +from pytrustnfe.certificado import extract_cert_and_key_from_pfx, save_cert_key +from pytrustnfe.nfse.assinatura import Assinatura + + +def sign_tag(certificado, **kwargs): + pkcs12 = crypto.load_pkcs12(certificado.pfx, certificado.password) + key = pkcs12.get_privatekey() + if 'nfse' in kwargs: + for item in kwargs['nfse']['lista_rps']: + signed = crypto.sign(key, item['assinatura'], 'SHA1') + item['assinatura'] = b64encode(signed) + if 'cancelamento' in kwargs: + signed = crypto.sign(key, kwargs['cancelamento']['assinatura'], 'SHA1') + kwargs['cancelamento']['assinatura'] = b64encode(signed) + + +def _send(certificado, method, **kwargs): + path = os.path.join(os.path.dirname(__file__), 'templates') + if method in ('GerarNfse', 'RecepcionarLoteRps', + 'RecepcionarLoteRpsSincrono', + 'CancelarNfse', 'SubstituirNfse'): + sign_tag(certificado, **kwargs) + + if kwargs['ambiente'] == 'producao': + url = \ + 'http://e-gov.betha.com.br/e-nota-contribuinte-test-ws/nfseWS?wsdl' + else: + url = 'http://e-gov.betha.com.br/e-nota-contribuinte-ws/nfseWS?wsdl' + + xml_send = render_xml(path, '%s.xml' % method, False, **kwargs) + + cert, key = extract_cert_and_key_from_pfx( + certificado.pfx, certificado.password) + cert, key = save_cert_key(cert, key) + client = get_authenticated_client(url, cert, key) + + pfx_path = certificado.save_pfx() + signer = Assinatura(pfx_path, certificado.password) + xml_send = signer.assina_xml(xml_send, '') + + try: + response = getattr(client.service, method)(1, xml_send) + except suds.WebFault, e: + return { + 'sent_xml': xml_send, + 'received_xml': e.fault.faultstring, + 'object': None + } + + response, obj = sanitize_response(response) + return { + 'sent_xml': xml_send, + 'received_xml': response, + 'object': obj + } + + +def gerar_nfse(certificado, **kwargs): + return _send(certificado, 'GerarNfse', **kwargs) + + +def envio_lote_rps_assincrono(certificado, **kwargs): + return _send(certificado, 'RecepcionarLoteRps', **kwargs) + + +def envio_lote_rps(certificado, **kwargs): + return _send(certificado, 'RecepcionarLoteRpsSincrono', **kwargs) + + +def cancelar_nfse(certificado, **kwargs): + return _send(certificado, 'CancelarNfse', **kwargs) + + +def substituir_nfse(certificado, **kwargs): + return _send(certificado, 'SubstituirNfse', **kwargs) + + +def consulta_situacao_lote_rps(certificado, **kwargs): + return _send(certificado, 'ConsultaSituacaoLoteRPS', **kwargs) + + +def consulta_nfse_por_rps(certificado, **kwargs): + return _send(certificado, 'ConsultaNfsePorRps', **kwargs) + + +def consultar_lote_rps(certificado, **kwargs): + return _send(certificado, 'ConsultarLoteRps', **kwargs) + + +def consulta_nfse_servico_prestado(certificado, **kwargs): + return _send(certificado, 'ConsultarNfseServicoPrestado', **kwargs) + + +def consultar_nfse_servico_tomado(certificado, **kwargs): + return _send(certificado, 'ConsultarNfseServicoTomado', **kwargs) + + +def consulta_nfse_faixe(certificado, **kwargs): + return _send(certificado, 'ConsultarNfseFaixa', **kwargs) + + +def consulta_cnpj(certificado, **kwargs): + return _send(certificado, 'ConsultaCNPJ', **kwargs) diff --git a/pytrustnfe/nfse/betha/templates/CancelarNfse.xml b/pytrustnfe/nfse/betha/templates/CancelarNfse.xml new file mode 100644 index 0000000..ecb5a16 --- /dev/null +++ b/pytrustnfe/nfse/betha/templates/CancelarNfse.xml @@ -0,0 +1,15 @@ + + + + + 58 + + 45111111111100 + + 123498 + 4204608 + + 1 + + + diff --git a/pytrustnfe/nfse/betha/templates/ConsultarLoteRps.xml b/pytrustnfe/nfse/betha/templates/ConsultarLoteRps.xml new file mode 100644 index 0000000..3861c49 --- /dev/null +++ b/pytrustnfe/nfse/betha/templates/ConsultarLoteRps.xml @@ -0,0 +1,8 @@ + + + + 45111111111100 + + + 141542179222170 + diff --git a/pytrustnfe/nfse/betha/templates/ConsultarNfseFaixa.xml b/pytrustnfe/nfse/betha/templates/ConsultarNfseFaixa.xml new file mode 100644 index 0000000..b223234 --- /dev/null +++ b/pytrustnfe/nfse/betha/templates/ConsultarNfseFaixa.xml @@ -0,0 +1,13 @@ + + + + 45111111111100 + + 123498 + + + 50 + 60 + + 1 + diff --git a/pytrustnfe/nfse/betha/templates/ConsultarNfsePorRps.xml b/pytrustnfe/nfse/betha/templates/ConsultarNfsePorRps.xml new file mode 100644 index 0000000..e86e16b --- /dev/null +++ b/pytrustnfe/nfse/betha/templates/ConsultarNfsePorRps.xml @@ -0,0 +1,13 @@ + + + 24 + A1 + 1 + + + + 45111111111100 + + 123498 + + diff --git a/pytrustnfe/nfse/betha/templates/ConsultarNfseServicoPrestado.xml b/pytrustnfe/nfse/betha/templates/ConsultarNfseServicoPrestado.xml new file mode 100644 index 0000000..421df7b --- /dev/null +++ b/pytrustnfe/nfse/betha/templates/ConsultarNfseServicoPrestado.xml @@ -0,0 +1,13 @@ + + + + 45111111111100 + + + 61 + + 2014-12-01 + 2014-12-31 + + 1 + diff --git a/pytrustnfe/nfse/betha/templates/ConsultarNfseServicoTomado.xml b/pytrustnfe/nfse/betha/templates/ConsultarNfseServicoTomado.xml new file mode 100644 index 0000000..1893693 --- /dev/null +++ b/pytrustnfe/nfse/betha/templates/ConsultarNfseServicoTomado.xml @@ -0,0 +1,27 @@ + + + + 45111111111100 + + + + 2014-01-01 + 2014-12-31 + + + + 45111111111100 + + + + + 83787494000123 + + + + + 45111111111100 + + + 1 + diff --git a/pytrustnfe/nfse/betha/templates/GerarNfse.xml b/pytrustnfe/nfse/betha/templates/GerarNfse.xml new file mode 100644 index 0000000..fdd22d1 --- /dev/null +++ b/pytrustnfe/nfse/betha/templates/GerarNfse.xml @@ -0,0 +1,3 @@ + + {% include 'rps.xml' %} + diff --git a/pytrustnfe/nfse/betha/templates/RecepcionarLoteRps.xml b/pytrustnfe/nfse/betha/templates/RecepcionarLoteRps.xml new file mode 100644 index 0000000..0b11051 --- /dev/null +++ b/pytrustnfe/nfse/betha/templates/RecepcionarLoteRps.xml @@ -0,0 +1,13 @@ + + + 2012024 + + 45111111111100 + + 123498 + 1 + + {% include 'rps.xml' %} + + + diff --git a/pytrustnfe/nfse/betha/templates/RecepcionarLoteRpsSincrono.xml b/pytrustnfe/nfse/betha/templates/RecepcionarLoteRpsSincrono.xml new file mode 100644 index 0000000..79f6eda --- /dev/null +++ b/pytrustnfe/nfse/betha/templates/RecepcionarLoteRpsSincrono.xml @@ -0,0 +1,13 @@ + + + 2012021 + + 45111111111100 + + 123498 + 1 + + {% include 'rps.xml' %} + + + diff --git a/pytrustnfe/nfse/betha/templates/Rps.xml b/pytrustnfe/nfse/betha/templates/Rps.xml new file mode 100644 index 0000000..2650c87 --- /dev/null +++ b/pytrustnfe/nfse/betha/templates/Rps.xml @@ -0,0 +1,78 @@ + + + + + 25 + A1 + 1 + + 2014-12-06 + 1 + + 2014-12-01 + + + 100 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + 2 + 0702 + 2525 + Prog. + 4204608 + 1 + 4204608 + + + + 45111111111100 + + 123498 + + + + + 83787494000123 + + + INSTITUICAO FINANCEIRA + + AV. 7 DE SETEMBRO + 1505 + AO LADO DO JOAO AUTOMOVEIS + CENTRO + 4201406 + SC + 88900000 + + + 4835220026 + luiz.alves@cxpostal.com + + + + + + 06410987065144 + + 22252 + + CONSTRUTORA TERRA FIRME + + + 142 + 1/2014 + + 3 + 2 + 2 + + diff --git a/pytrustnfe/nfse/betha/templates/SubstituirNfse.xml b/pytrustnfe/nfse/betha/templates/SubstituirNfse.xml new file mode 100644 index 0000000..294c0d0 --- /dev/null +++ b/pytrustnfe/nfse/betha/templates/SubstituirNfse.xml @@ -0,0 +1,18 @@ + + + + + + 57 + + 45111111111100 + + 123498 + 4204608 + + 2 + + + {% include 'rps.xml' %} + + diff --git a/pytrustnfe/nfse/ginfes/__init__.py b/pytrustnfe/nfse/ginfes/__init__.py new file mode 100644 index 0000000..449d2f8 --- /dev/null +++ b/pytrustnfe/nfse/ginfes/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +# © 2016 Danimar Ribeiro, Trustcode +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/pytrustnfe/nfse/issintel/__init__.py b/pytrustnfe/nfse/issintel/__init__.py new file mode 100644 index 0000000..449d2f8 --- /dev/null +++ b/pytrustnfe/nfse/issintel/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +# © 2016 Danimar Ribeiro, Trustcode +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/pytrustnfe/nfse/issnet/__init__.py b/pytrustnfe/nfse/issnet/__init__.py new file mode 100644 index 0000000..449d2f8 --- /dev/null +++ b/pytrustnfe/nfse/issnet/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +# © 2016 Danimar Ribeiro, Trustcode +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/pytrustnfe/nfse/saatri/__init__.py b/pytrustnfe/nfse/saatri/__init__.py new file mode 100644 index 0000000..449d2f8 --- /dev/null +++ b/pytrustnfe/nfse/saatri/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +# © 2016 Danimar Ribeiro, Trustcode +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/pytrustnfe/nfse/webiss/__init__.py b/pytrustnfe/nfse/webiss/__init__.py new file mode 100644 index 0000000..449d2f8 --- /dev/null +++ b/pytrustnfe/nfse/webiss/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +# © 2016 Danimar Ribeiro, Trustcode +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/pytrustnfe/test/XMLs/paulistana_signature.xml b/pytrustnfe/test/XMLs/paulistana_signature.xml new file mode 100644 index 0000000..013053e --- /dev/null +++ b/pytrustnfe/test/XMLs/paulistana_signature.xml @@ -0,0 +1,37 @@ + +12345678901234false2016-08-292016-08-291E4fpHYkQa7Naxn6IKGb7NwwZu5tPk/KXJ9hCwtZgq0xvKS450aQqqBL+7Iv46lTgqrSMu7+gLrl+LC1qs/8aT2mbHE8uaVFSbzwZ+sF/BkcT6nsFHLMswEiTAEs95Jb7hN1cC91xqQGRH4buw0TzxHKmhuLJ22WwtG/scxyKtjM=12345611RPS2016-08-29NT0.000.000.000.000.00074985.00false + + + 123456Trustcode1Vinicius de Moraes, 4242CorregoFloripaSC88037240Venda de servico + + + + + + + + + +ivaOwkcrt0pfuMYsAdfyLaUAcIk= + + +FjIHdfPavSEyaWYhAT0z0shPLuTsqBKyy78PUEZ8PUhTZ+iSV0MOvAIRq9MPPVK9 +jjXOw1TE903uSK8aJon52RNKPd68ORVJ3bKFSjTqQLxFRR9tiiAQFrWDETf7FF89 +EhG6dy6TGcgVbOyn0Jqm8MkqrE1XrJ44orN1X+Jt+7U= + + +MIICMTCCAZqgAwIBAgIQfYOsIEVuAJ1FwwcTrY0t1DANBgkqhkiG9w0BAQUFADBX +MVUwUwYDVQQDHkwAewA1ADkARgAxAEUANAA2ADEALQBEAEQARQA1AC0ANABEADIA +RgAtAEEAMAAxAEEALQA4ADMAMwAyADIAQQA5AEUAQgA4ADMAOAB9MB4XDTE1MDYx +NTA1NDc1N1oXDTE2MDYxNDExNDc1N1owVzFVMFMGA1UEAx5MAHsANQA5AEYAMQBF +ADQANgAxAC0ARABEAEUANQAtADQARAAyAEYALQBBADAAMQBBAC0AOAAzADMAMgAy +AEEAOQBFAEIAOAAzADgAfTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAk41G +nqXXLaiOC/y0/cA4tbS+NZCqI+x4EsztgDFvPPlHstiVYcLRkni4i93gK9zoC6g0 +mh66HMVzAfE8vRNwW5b7m6nWS1SiHBon7/Mqsw4MIq3SC+J/fTbKpqwyfAuH2YZl +AiQuQc85fyllAMLh2WrA7JgOLR/5tF3kLtpbHdECAwEAATANBgkqhkiG9w0BAQUF +AAOBgQArdh+RyT6VxKGsXk1zhHsgwXfToe6GpTF4W8PHI1+T0WIsNForDhvst6nm +QtgAhuZM9rxpOJuNKc+pM29EixpAiZZiRMCSWEItNyEVdUIi+YnKBcAHd88TwO86 +d126MWQ2O8cu5W1VoDp7hYBYKOnLbYi11/StO+0rzK+oPYAvIw== + + + diff --git a/pytrustnfe/test/test_nfse_paulistana.py b/pytrustnfe/test/test_nfse_paulistana.py index 2ebd568..0ed4ded 100644 --- a/pytrustnfe/test/test_nfse_paulistana.py +++ b/pytrustnfe/test/test_nfse_paulistana.py @@ -6,15 +6,15 @@ import unittest from pytrustnfe.certificado import Certificado from pytrustnfe.nfse.paulistana import envio_lote_rps from pytrustnfe.nfse.paulistana import cancelamento_nfe +from pytrustnfe.nfse.assinatura import Assinatura +from pytrustnfe.nfse.paulistana import sign_tag class test_nfse_paulistana(unittest.TestCase): caminho = os.path.dirname(__file__) - def test_envio_nfse(self): - pfx_source = open(os.path.join(self.caminho, 'teste.pfx'), 'r').read() - pfx = Certificado(pfx_source, '123456') + def _get_nfse(self): rps = [ { 'assinatura': '123', @@ -51,7 +51,13 @@ class test_nfse_paulistana(unittest.TestCase): 'data_fim': '2016-08-29', 'lista_rps': rps } + return nfse + def test_envio_nfse(self): + pfx_source = open(os.path.join(self.caminho, 'teste.pfx'), 'r').read() + pfx = Certificado(pfx_source, '123456') + + nfse = self._get_nfse() path = os.path.join(os.path.dirname(__file__), 'XMLs') xml_return = open(os.path.join( path, 'paulistana_resultado.xml'), 'r').read() @@ -70,6 +76,23 @@ class test_nfse_paulistana(unittest.TestCase): self.assertEqual( retorno['object'].ChaveNFeRPS.ChaveRPS.NumeroRPS, 6) + def test_nfse_signature(self): + pfx_source = open(os.path.join(self.caminho, 'teste.pfx'), 'r').read() + pfx = Certificado(pfx_source, '123456') + + nfse = self._get_nfse() + path = os.path.join(os.path.dirname(__file__), 'XMLs') + xml_sent = open(os.path.join( + path, 'paulistana_signature.xml'), 'r').read() + + with mock.patch('pytrustnfe.nfse.paulistana.get_authenticated_client') as client: + retorno = mock.MagicMock() + client.return_value = retorno + retorno.service.EnvioLoteRPS.return_value = '' + + retorno = envio_lote_rps(pfx, nfse=nfse) + self.assertEqual(retorno['sent_xml'], xml_sent) + def _get_cancelamento(self): return { 'cnpj_remetente': '123',