Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ omit =
*iibb*
*nsis*
*/padron.py
*pyi25*
*rece1*
*receb1*
*recem*
Expand Down
2 changes: 1 addition & 1 deletion pyi25.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def main():

if not "--mostrar" in sys.argv:
pass
elif sys.platform == "linux2":
elif sys.platform == "linux2" or sys.platform == "linux":
os.system("eog " "%s" "" % archivo)
else:
os.startfile(archivo)
Expand Down
Binary file added tests/images/prueba-cae-i25.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
87 changes: 87 additions & 0 deletions tests/test_pyi25.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/python
# -*- coding: utf8 -*-
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.

"""Test para pyi25"""

__author__ = "Mariano Reingart <[email protected]>"
__copyright__ = "Copyright (C) 2010-2019 Mariano Reingart"
__license__ = "GPL 3.0"


from builtins import str
from builtins import range
from builtins import object
from past.utils import old_div

import os
import sys
import pytest

from pyafipws.pyi25 import PyI25, main
from PIL import Image, ImageChops

pytestmark = [pytest.mark.dontusefix]

pyi25 = PyI25()

def test_GenerarImagen():
"Prueba de generación de imagen"
barras = "2026756539302400161203034739042201105299"
archivo = "prueba.png"
pyi25.GenerarImagen(barras, archivo)

assert os.path.exists(archivo)
#compare the image with a reference one
ref = Image.open("tests/images/prueba-cae-i25.png")
test = Image.open(archivo)
diff = ImageChops.difference(ref, test)
assert diff.getbbox() is None


def test_DigitoVerificadorModulo10():
"Prueba de verificación de Dígitos de Verificación Modulo 10"
cuit = 20267565393
tipo_cbte = 2
punto_vta = 4001
cae = 61203034739042
fch_venc_cae = 20110529

# codigo de barras de ejemplo:
barras = "%11s%02d%04d%s%8s" % (
cuit,
tipo_cbte,
punto_vta,
cae,
fch_venc_cae,
)

barras = barras + pyi25.DigitoVerificadorModulo10(barras)
assert barras == "2026756539302400161203034739042201105299"

def test_main():
sys.argv = []
main()

def test_main_archivo():
sys.argv = []
sys.argv.append("--archivo")
sys.argv.append("test123.png")
main()

def test_main_mostrar(mocker):
mocker.patch("os.system")
sys.argv = []
sys.argv.append("--mostrar")
archivo = "prueba-cae-i25.png"
main()
if(sys.platform == 'linux2' or sys.platform == 'linux'):
os.system.assert_called_with("eog " "%s" "" % archivo)