From ad7593f53dff79ef23de9e78d3656c9ad0b173ed Mon Sep 17 00:00:00 2001 From: Mauricio Baeza Date: Fri, 11 Dec 2020 16:35:54 -0600 Subject: [PATCH] =?UTF-8?q?Agregar=20validaciones=20a=20test=20de=20cancel?= =?UTF-8?q?aci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/comerciodigital/comercio.py | 2 +- source/tests/tests_comercio.py | 43 +++++++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/source/comerciodigital/comercio.py b/source/comerciodigital/comercio.py index 0b2b47b..ad9d985 100644 --- a/source/comerciodigital/comercio.py +++ b/source/comerciodigital/comercio.py @@ -167,7 +167,7 @@ class PACComercioDigital(object): f"PWDK={info['pass']}", f"KEYF={info['key']}", f"CERT={info['cer']}", - f"TIPO={info['tipo']}", # cfdi3.3 o reten1.0 + f"TIPO={info['tipo']}", f"ACUS=SI", f"RFCR={rfc_receptor}", f"TIPOC={tipo}", diff --git a/source/tests/tests_comercio.py b/source/tests/tests_comercio.py index f87fac9..74ff0e9 100644 --- a/source/tests/tests_comercio.py +++ b/source/tests/tests_comercio.py @@ -38,6 +38,37 @@ TEMPLATE_CFDI = """ """ + +TEMPLATE_CANCEL = """ + + {uuid} + + + + + + + + + + + + + + + + + + + + + + + + +""" + + class TestCfdi(object): def __init__(self): @@ -100,6 +131,7 @@ class TestStamp(unittest.TestCase): self.assertTrue(bool(uuid.UUID(cfdi_uuid))) def test_cfdi_cancel(self): + expected = '201' cfdi = TestCfdi() result = self.pac.stamp(cfdi.xml) cfdi_uuid = self.pac.cfdi_uuid @@ -112,13 +144,18 @@ class TestStamp(unittest.TestCase): info = { 'key': cert[0], 'cer': cert[1], - 'pass': '12345678', + 'pass': '12345678a', 'tipo': 'cfdi3.3', } result = self.pac.cancel(result, info) - self.assertFalse(bool(self.pac.error)) - self.assertTrue(bool(result)) + + tree = ET.fromstring(result) + cancel_uuid = tree.xpath('string(//Acuse/Folios/UUID)') + status = tree.xpath('string(//Acuse/Folios/EstatusUUID)') + + self.assertEqual(cfdi_uuid, cancel_uuid) + self.assertEqual(status, expected) if __name__ == '__main__':