Skip to content

Commit

Permalink
nfse: tribNac->tribFed adjust samples and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rvalyi committed May 26, 2024
1 parent 39a9503 commit 2c5bd2e
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 74 deletions.
6 changes: 3 additions & 3 deletions nfelib/nfse/samples/v1_0/ConsultarNFSeEnvio-ped-sitnfse.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@
<tribISSQN>1</tribISSQN>
<tpRetISSQN>1</tpRetISSQN>
</tribMun>
<tribNac>
<tribFed>
<vRetCP>8.99</vRetCP>
<vRetIRRF>9.99</vRetIRRF>
<vRetCSLL>9.99</vRetCSLL>
</tribNac>
</tribFed>
<totTrib>
<pTotTribSN>0.01</pTotTribSN>
</totTrib>
Expand Down Expand Up @@ -125,4 +125,4 @@
</X509Data>
</KeyInfo>
</Signature>
</NFSe>
</NFSe>
6 changes: 3 additions & 3 deletions nfelib/nfse/samples/v1_0/ConsultarNFSeRPS-ped-sitnfserps.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
<tribISSQN>1</tribISSQN>
<tpRetISSQN>1</tpRetISSQN>
</tribMun>
<tribNac>
<tribFed>
<vRetCP>8.99</vRetCP>
<vRetIRRF>9.99</vRetIRRF>
<vRetCSLL>9.99</vRetCSLL>
</tribNac>
</tribFed>
<totTrib>
<pTotTribSN>0.01</pTotTribSN>
</totTrib>
</trib>
</valores>
</infDPS>
</DPS>
</DPS>
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,16 @@
<vDescCondIncond>
<vDescIncond>9999999.99</vDescIncond>
<vDescCond>9.99</vDescCond>
</vDescCondIncond>
<trib>
<tribMun>
<tribISSQN>1</tribISSQN>
<tpRetISSQN>1</tpRetISSQN>
</tribMun>
<tribNac>
<vRetCP>8.99</vRetCP>
<vRetIRRF>9.99</vRetIRRF>
<vRetCSLL>9.99</vRetCSLL>
</tribNac>
<totTrib>
<pTotTribSN>0.01</pTotTribSN>
</totTrib>
</trib>
</vDescCondIncond>
<trib>
<tribMun>
<tribISSQN>1</tribISSQN>
<tpRetISSQN>1</tpRetISSQN>
</tribMun>
<totTrib>
<pTotTribSN>0.01</pTotTribSN>
</totTrib>
</trib>
</valores>
</infDPS>
</DPS>
</DPS>
106 changes: 54 additions & 52 deletions tests/nfse/test_nfse.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Copyright (C) 2019 - TODAY Raphaël Valyi - Akretion
# Copyright (C) 2023 - TODAY Raphaël Valyi - Akretion

import os
from xmldiff import main
from unittest import TestCase

from xsdata.formats.dataclass.serializers.config import SerializerConfig
from xsdata.formats.dataclass.parsers import XmlParser
Expand All @@ -12,62 +13,63 @@
from nfelib.nfse.bindings.v1_0 import dps_v1_00


def test_in_out_nfse():
path = os.path.join("nfelib", "nfse", "samples", "v1_0")
for filename in ["ConsultarNFSeEnvio-ped-sitnfse.xml"]:
input_file = os.path.join(path, filename)
parser = XmlParser()
obj = parser.from_path(Path(input_file))
serializer = XmlSerializer(config=SerializerConfig(pretty_print=True))
xml = serializer.render(
obj=obj, ns_map={None: "http://www.sped.fazenda.gov.br/nfse"}
)
class NFseTests(TestCase):
def test_in_out_consulta(self):
path = os.path.join("nfelib", "nfse", "samples", "v1_0")
for filename in ["ConsultarNFSeEnvio-ped-sitnfse.xml"]:
input_file = os.path.join(path, filename)
parser = XmlParser()
obj = parser.from_path(Path(input_file))
serializer = XmlSerializer(config=SerializerConfig(pretty_print=True))
xml = serializer.render(
obj=obj, ns_map={None: "http://www.sped.fazenda.gov.br/nfse"}
)

output_file = "tests/output_nfse.xml"
with open(output_file, "w") as f:
f.write(xml)
output_file = "tests/output_nfse.xml"
with open(output_file, "w") as f:
f.write(xml)

diff = main.diff_files(input_file, output_file)
assert len(diff) == 0
if len(diff) != 0:
break
diff = main.diff_files(input_file, output_file)
assert len(diff) == 0
if len(diff) != 0:
break

def test_in_out_dps():
path = os.path.join("nfelib", "nfse", "samples", "v1_0")
for filename in ["GerarNFSeEnvio-env-loterps.xml", "ConsultarNFSeRPS-ped-sitnfserps.xml"]:
input_file = os.path.join(path, filename)
parser = XmlParser()
obj = parser.from_path(Path(input_file))
serializer = XmlSerializer(config=SerializerConfig(pretty_print=True))
xml = serializer.render(
obj=obj, ns_map={None: "http://www.sped.fazenda.gov.br/nfse"}
)
def test_in_out_dps(self):
path = os.path.join("nfelib", "nfse", "samples", "v1_0")
for filename in ["dps-simples.xml", "dps-regime-normal.xml"]:
input_file = os.path.join(path, filename)
parser = XmlParser()
obj = parser.from_path(Path(input_file))
serializer = XmlSerializer(config=SerializerConfig(pretty_print=True))
xml = serializer.render(
obj=obj, ns_map={None: "http://www.sped.fazenda.gov.br/nfse"}
)

output_file = "tests/output_nfse_dps.xml"
with open(output_file, "w") as f:
f.write(xml)
output_file = "tests/output_nfse_dps.xml"
with open(output_file, "w") as f:
f.write(xml)

diff = main.diff_files(input_file, output_file)
assert len(diff) == 0
if len(diff) != 0:
break
diff = main.diff_files(input_file, output_file)
assert len(diff) == 0
if len(diff) != 0:
break

def test_in_out_pedRegEvento():
path = os.path.join("nfelib", "nfse", "samples", "v1_0")
for filename in ["CancelarNFSe-ped-cannfse.xml"]:
input_file = os.path.join(path, filename)
parser = XmlParser()
obj = parser.from_path(Path(input_file))
serializer = XmlSerializer(config=SerializerConfig(pretty_print=True))
xml = serializer.render(
obj=obj, ns_map={None: "http://www.sped.fazenda.gov.br/nfse"}
)
def test_in_out_pedRegEvento(self):
path = os.path.join("nfelib", "nfse", "samples", "v1_0")
for filename in ["CancelarNFSe-ped-cannfse.xml"]:
input_file = os.path.join(path, filename)
parser = XmlParser()
obj = parser.from_path(Path(input_file))
serializer = XmlSerializer(config=SerializerConfig(pretty_print=True))
xml = serializer.render(
obj=obj, ns_map={None: "http://www.sped.fazenda.gov.br/nfse"}
)

output_file = "tests/output_nfse_pedRegEvento.xml"
with open(output_file, "w") as f:
f.write(xml)
output_file = "tests/output_nfse_pedRegEvento.xml"
with open(output_file, "w") as f:
f.write(xml)

diff = main.diff_files(input_file, output_file)
assert len(diff) == 0
if len(diff) != 0:
break
diff = main.diff_files(input_file, output_file)
assert len(diff) == 0
if len(diff) != 0:
break

0 comments on commit 2c5bd2e

Please sign in to comment.