Skip to content

Commit

Permalink
added pdf render test
Browse files Browse the repository at this point in the history
  • Loading branch information
satcfdi committed Oct 1, 2023
1 parent 5a98978 commit 6260f54
Showing 1 changed file with 1 addition and 56 deletions.
57 changes: 1 addition & 56 deletions tests/test_create_cfdi40.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,62 +90,7 @@ def test_traslados_incluidos():

assert invoice["Total"] == valor * Decimal('23.00')


@pytest.mark.parametrize('rfc, xml_file, traslados, retenciones, total, traslado_incluido', invoices)
@pytest.mark.skip(reason="skiping render for performance reasons")
def test_create_invoice_render(rfc, xml_file, traslados, retenciones, total, traslado_incluido):
xml_file = "_render" + xml_file
signer = get_signer(rfc)
emisor = cfdi40.Emisor(
rfc=signer.rfc,
nombre=signer.legal_name,
regimen_fiscal="601"
)

invoice = cfdi40.Comprobante(
emisor=emisor,
lugar_expedicion="56820",
fecha=datetime.fromisoformat("2020-01-01T22:40:38"),
receptor=cfdi40.Receptor(
rfc='KIJ0906199R1',
nombre='KIJ, S.A DE C.V.',
uso_cfdi='G03',
domicilio_fiscal_receptor="59820",
regimen_fiscal_receptor="601"
),
metodo_pago='PPD',
serie="A",
folio="123456",
conceptos=[
cfdi40.Concepto(
cuenta_predial='1234567890',
clave_prod_serv='10101702',
cantidad=Decimal('1.00'),
clave_unidad='E48',
descripcion='SERVICIOS DE FACTURACION',
valor_unitario=Decimal('15390.30'),
impuestos=cfdi40.Impuestos(
traslados=traslados,
retenciones=retenciones,
),
_traslados_incluidos=traslado_incluido,
)
]
)
invoice.sign(signer)

assert invoice["Total"] == Decimal(total)

# Stamping
with mock.patch('uuid.uuid4', _uuid), \
mock.patch(f'{module}.Certificate.rfc_pac', get_rfc_pac):
stamp_v11(invoice, signer=signer, date=datetime(year=2020, month=1, day=11))

path = f"{xml_file}_stamped"

os.makedirs(os.path.join(current_dir, 'renders'), exist_ok=True)
render.html_write(invoice, target=os.path.join(current_dir, 'renders', f"{path}.html"))
render.pdf_write(invoice, target=os.path.join(current_dir, 'renders', f"{path}.pdf"))
render.pdf_write(invoice, target=os.path.join(current_dir, current_filename, f"test_traslados_incluidos_render.pdf"))


@pytest.mark.parametrize('rfc, xml_file, traslados, retenciones, total, traslado_incluido', invoices)
Expand Down

0 comments on commit 6260f54

Please sign in to comment.