forked from pysimplesoap/pysimplesoap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnfp_br_test.py
68 lines (54 loc) · 2.89 KB
/
nfp_br_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/python
# -*- coding: utf-8 -*-
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
"""Brazil - Sao Paulo "Electronic Invoice" (Nota Fiscal Paulista)"""
from __future__ import unicode_literals
from decimal import Decimal
import os
import unittest
from pysimplesoap.client import SoapClient, SoapFault, SimpleXMLElement
import sys
if sys.version > '3':
basestring = str
long = int
# Documentation: http://www.nfp.fazenda.sp.gov.br/MIWSCF.pdf
WSDL = 'https://www.nfp.fazenda.sp.gov.br/ws/arquivocf.asmx?WSDL'
HEADER_XML = """<Autenticacao Usuario="%s" Senha="%s" CNPJ="%s"
CategoriaUsuario="%d" xmlns="https://www.nfp.sp.gov.br/ws" />"""
# TODO: support attributes in headers / parameters
class TestNFP(unittest.TestCase):
def test_enviar(self):
"Prueba da envio de arquivos de cupons fiscais"
# create the client webservice
client = SoapClient(wsdl=WSDL, soap_ns="soap12env")
# set user login credentials in the soap header:
client['Autenticacao'] = SimpleXMLElement(HEADER_XML % ("user","password", "fed_tax_num", 1))
# call the webservice
response = client.Enviar(NomeArquivo="file_name", ConteudoArquivo="content", EnvioNormal=True, Observacoes="")
self.assertEqual(response['EnviarResult'], '206|CNPJ informado inv\xe1lido')
def test_consultar(self):
"consulta ao resultado do processamento dos arquivos de cupons fiscai"
# create the client webservice
client = SoapClient(wsdl=WSDL, soap_ns="soap12env")
# set user login credentials in the soap header:
client['Autenticacao'] = SimpleXMLElement(HEADER_XML % ("user","password", "fed_tax_num", 1))
# call the webservice
response = client.Consultar(Protocolo="")
self.assertEqual(response['ConsultarResult'], '999|O protocolo informado n\xe3o \xe9 um n\xfamero v\xe1lido')
def test_retificar(self):
"Prueba da retifica de arquivos de cupons fiscais"
# create the client webservice
client = SoapClient(wsdl=WSDL, soap_ns="soap12env")
# set user login credentials in the soap header:
client['Autenticacao'] = SimpleXMLElement(HEADER_XML % ("user","password", "fed_tax_num", 1))
# call the webservice
response = client.Retificar(NomeArquivo="file_name", ConteudoArquivo="content", EnvioNormal=True, Observacoes="")
self.assertEqual(response['RetificarResult'], '206|CNPJ informado inv\xe1lido')