Skip to content

Commit

Permalink
Merge pull request #98 from chazuttu/test_pdf_gen
Browse files Browse the repository at this point in the history
added support for testing pdf generation
  • Loading branch information
reingart authored Nov 15, 2021
2 parents 78d5a06 + ec737f8 commit c687f4d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pyfepdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ def main():
# datos generales del encabezado:
tipo_cbte = 19 if "--expo" in sys.argv else 201
punto_vta = 4000
fecha = datetime.datetime.now().strftime("%Y%m%d")
fecha = '20210805' if "--fecha_prueba" in sys.argv else datetime.datetime.now().strftime("%Y%m%d")
concepto = 3
tipo_doc = 80
nro_doc = "30000000007"
Expand Down
26 changes: 16 additions & 10 deletions tests/test_pyfepdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,18 +311,22 @@ def test_main_cargar_json():
def test_main_grabar():
sys.argv = []
sys.argv.append("--prueba")
sys.argv.append("--fecha_prueba")
sys.argv.append("--grabar")
# sys.argv.append("--debug")
main()
#TO-DO : compare the generated facturas.txt with the original file
# f1 = open("facturas.txt", "r")
# f2 = open("tests/facturas.txt", "r")
# d1 = f1.readlines()
# d2 = f2.readlines()
# f1.close()
# f2.close()
# diff = [x for x in d1 if x not in d2]
# assert diff == []
f1 = open("facturas.txt", "r")
f2 = open("tests/facturas.txt", "r")

d1 = f1.readlines()
d2 = f2.readlines()
if sys.version_info[0] < 3:
d2 = [d.replace("\xc2", "") for d in d2]
d2 = [d.replace("\xc3\xb3", "\xf3") for d in d2]
f1.close()
f2.close()
diff1 = [x for x in d2 if x not in d1]
assert diff1 == []



def test_main_grabar_json():
Expand All @@ -340,6 +344,8 @@ def test_main_grabar_json():
f2.close()
diff = [x for x in d1 if x not in d2]
assert diff == []
os.remove('facturas.txt')
os.remove('facturas.json')


def test_mostrar_pdf(mocker):
Expand Down

0 comments on commit c687f4d

Please sign in to comment.