Agregar validaciones a test de cancelación
This commit is contained in:
parent
be29df47fe
commit
ad7593f53d
|
@ -167,7 +167,7 @@ class PACComercioDigital(object):
|
||||||
f"PWDK={info['pass']}",
|
f"PWDK={info['pass']}",
|
||||||
f"KEYF={info['key']}",
|
f"KEYF={info['key']}",
|
||||||
f"CERT={info['cer']}",
|
f"CERT={info['cer']}",
|
||||||
f"TIPO={info['tipo']}", # cfdi3.3 o reten1.0
|
f"TIPO={info['tipo']}",
|
||||||
f"ACUS=SI",
|
f"ACUS=SI",
|
||||||
f"RFCR={rfc_receptor}",
|
f"RFCR={rfc_receptor}",
|
||||||
f"TIPOC={tipo}",
|
f"TIPOC={tipo}",
|
||||||
|
|
|
@ -38,6 +38,37 @@ TEMPLATE_CFDI = """<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/3" xm
|
||||||
</cfdi:Comprobante>
|
</cfdi:Comprobante>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
TEMPLATE_CANCEL = """<Cancelacion RfcEmisor="{rfc}" Fecha="{fecha}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://cancelacfd.sat.gob.mx">
|
||||||
|
<Folios>
|
||||||
|
<UUID>{uuid}</UUID>
|
||||||
|
</Folios>
|
||||||
|
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
|
||||||
|
<SignedInfo>
|
||||||
|
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
|
||||||
|
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
|
||||||
|
<Reference URI="">
|
||||||
|
<Transforms>
|
||||||
|
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
|
||||||
|
</Transforms>
|
||||||
|
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
|
||||||
|
<DigestValue />
|
||||||
|
</Reference>
|
||||||
|
</SignedInfo>
|
||||||
|
<SignatureValue />
|
||||||
|
<KeyInfo>
|
||||||
|
<X509Data>
|
||||||
|
<X509SubjectName />
|
||||||
|
<X509IssuerSerial />
|
||||||
|
<X509Certificate />
|
||||||
|
</X509Data>
|
||||||
|
<KeyValue />
|
||||||
|
</KeyInfo>
|
||||||
|
</Signature>
|
||||||
|
</Cancelacion>
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class TestCfdi(object):
|
class TestCfdi(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -100,6 +131,7 @@ class TestStamp(unittest.TestCase):
|
||||||
self.assertTrue(bool(uuid.UUID(cfdi_uuid)))
|
self.assertTrue(bool(uuid.UUID(cfdi_uuid)))
|
||||||
|
|
||||||
def test_cfdi_cancel(self):
|
def test_cfdi_cancel(self):
|
||||||
|
expected = '201'
|
||||||
cfdi = TestCfdi()
|
cfdi = TestCfdi()
|
||||||
result = self.pac.stamp(cfdi.xml)
|
result = self.pac.stamp(cfdi.xml)
|
||||||
cfdi_uuid = self.pac.cfdi_uuid
|
cfdi_uuid = self.pac.cfdi_uuid
|
||||||
|
@ -112,13 +144,18 @@ class TestStamp(unittest.TestCase):
|
||||||
info = {
|
info = {
|
||||||
'key': cert[0],
|
'key': cert[0],
|
||||||
'cer': cert[1],
|
'cer': cert[1],
|
||||||
'pass': '12345678',
|
'pass': '12345678a',
|
||||||
'tipo': 'cfdi3.3',
|
'tipo': 'cfdi3.3',
|
||||||
}
|
}
|
||||||
result = self.pac.cancel(result, info)
|
result = self.pac.cancel(result, info)
|
||||||
|
|
||||||
self.assertFalse(bool(self.pac.error))
|
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__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue