Agregar test de cancelación
This commit is contained in:
parent
6e98e016f2
commit
be29df47fe
|
@ -1,7 +1,9 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import base64
|
||||
import datetime
|
||||
import sys
|
||||
import time
|
||||
import unittest
|
||||
import uuid
|
||||
import lxml.etree as ET
|
||||
|
@ -15,6 +17,7 @@ from comerciodigital import PACComercioDigital
|
|||
|
||||
NAME = 'comercio'
|
||||
|
||||
|
||||
TEMPLATE_CFDI = """<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" LugarExpedicion="06850" Moneda="MXN" SubTotal="10000.00" TipoCambio="1" TipoDeComprobante="I" Total="11600.00" FormaPago="01" MetodoPago="PUE" Version="3.3" xsi:schemaLocation="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv33.xsd">
|
||||
<cfdi:Emisor Rfc="EKU9003173C9" RegimenFiscal="601"/>
|
||||
<cfdi:Receptor Rfc="BASM740115RW0" UsoCFDI="G01"/>
|
||||
|
@ -50,8 +53,8 @@ class TestCfdi(object):
|
|||
path_cer = Path(path.parent).joinpath('certificados', f'{NAME}.cer')
|
||||
path_key = Path(path.parent).joinpath('certificados', f'{NAME}.enc')
|
||||
path_xslt = Path(path.parent).joinpath('xslt', 'cadena.xslt')
|
||||
cer = path_cer.read_bytes()
|
||||
key = path_key.read_bytes()
|
||||
self._cer_ori = cer = path_cer.read_bytes()
|
||||
self._key_ori = key = path_key.read_bytes()
|
||||
|
||||
self._cert = SATCertificate(cer, key)
|
||||
self._doc = ET.parse(BytesIO(TEMPLATE_CFDI.encode()))
|
||||
|
@ -75,6 +78,12 @@ class TestCfdi(object):
|
|||
xslt.close()
|
||||
return
|
||||
|
||||
@property
|
||||
def cert(self):
|
||||
cer = base64.b64encode(self._cer_ori).decode()
|
||||
key = base64.b64encode(self._key_ori).decode()
|
||||
return key, cer
|
||||
|
||||
|
||||
class TestStamp(unittest.TestCase):
|
||||
|
||||
|
@ -90,6 +99,27 @@ class TestStamp(unittest.TestCase):
|
|||
self.assertFalse(bool(self.pac.error))
|
||||
self.assertTrue(bool(uuid.UUID(cfdi_uuid)))
|
||||
|
||||
def test_cfdi_cancel(self):
|
||||
cfdi = TestCfdi()
|
||||
result = self.pac.stamp(cfdi.xml)
|
||||
cfdi_uuid = self.pac.cfdi_uuid
|
||||
|
||||
self.assertFalse(bool(self.pac.error))
|
||||
self.assertTrue(bool(uuid.UUID(cfdi_uuid)))
|
||||
|
||||
time.sleep(1)
|
||||
cert = cfdi.cert
|
||||
info = {
|
||||
'key': cert[0],
|
||||
'cer': cert[1],
|
||||
'pass': '12345678',
|
||||
'tipo': 'cfdi3.3',
|
||||
}
|
||||
result = self.pac.cancel(result, info)
|
||||
|
||||
self.assertFalse(bool(self.pac.error))
|
||||
self.assertTrue(bool(result))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue