Skip to content

Commit

Permalink
Merge pull request reingart#64 from chazuttu/version_issues_fixed
Browse files Browse the repository at this point in the history
Python Version issues fixed
  • Loading branch information
reingart authored Jun 30, 2021
2 parents 33b5895 + 6778dd6 commit 3dfc2d1
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 31 deletions.
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
markers =
dontusefix: Dont use fixture in the current file
9 changes: 7 additions & 2 deletions tests/test_wsaa.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_crear_clave_privada():
chk = wsaa.CrearClavePrivada()
assert chk==True

@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7 or higher")

def test_crear_pedido_certificado():
"""Crea CSM para solicitar certificado."""
wsaa=WSAA()
Expand All @@ -78,7 +78,7 @@ def test_expirado():
assert chk2==True
assert chk3==False

@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7 or higher")

@pytest.mark.vcr
def test_login_cms(key_and_cert):
"""comprobando si LoginCMS está funcionando correctamente"""
Expand All @@ -91,7 +91,12 @@ def test_login_cms(key_and_cert):

ta = SimpleXMLElement(ta_xml)

if not isinstance(cms,str):
cms = cms.decode('utf-8')

assert isinstance(cms,str)


assert cms.startswith('MIIG+')

assert chk==True
Expand Down
9 changes: 6 additions & 3 deletions tests/test_wsbfev1.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
__copyright__ = "Copyright (C) 2010-2019 Mariano Reingart"
__license__ = "GPL 3.0"

import unittest
import os
import sys
from datetime import datetime, timedelta
import pytest
from pyafipws.wsaa import WSAA
from pyafipws.wsbfev1 import WSBFEv1
from pysimplesoap.simplexml import SimpleXMLElement
from pysimplesoap.simplexml import SimpleXMLElement
from builtins import str

__WSDL__ = "http://wswhomo.afip.gov.ar/WSBFEv1/service.asmx"
__obj__ = WSBFEv1()
Expand Down Expand Up @@ -146,7 +146,7 @@ def test_agregar_opcional(auth):
opcional = wsbfev1.AgregarOpcional(idz, ds)
assert opcional==True

@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7 or higher")

def test_autorizar(auth):
"""Test Autorizar Comprobante."""
wsbfev1 =auth
Expand All @@ -158,7 +158,10 @@ def test_autorizar(auth):
wsbfev1.Authorize(idx)

assert (wsbfev1.Resultado== "A")

assert isinstance(wsbfev1.CAE,str)


assert (wsbfev1.CAE)
# ten = datetime.now() + timedelta(days=10)
# assert (wsbfev1.Vencimiento == ten.strftime("%d/%m/%Y"))
Expand Down
12 changes: 9 additions & 3 deletions tests/test_wsfev1.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from pyafipws.wsaa import WSAA
from pyafipws.wsfev1 import WSFEv1
from builtins import str

"Pruebas para WSFEv1 de AFIP (Factura Electrónica Mercado Interno sin detalle)"

Expand All @@ -23,6 +24,7 @@
import sys
import pytest
import os
import future

__WSDL__ = "https://wswhomo.afip.gov.ar/wsfev1/service.asmx"
__obj__ = WSFEv1()
Expand All @@ -48,7 +50,7 @@ def test_dummy(auth):
assert (wsfev1.DbServerStatus== "OK")
assert (wsfev1.AuthServerStatus== "OK")

@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7 or higher")

def test_autorizar_comprobante(auth, tipo_cbte=1, cbte_nro=None, servicios=True):
"Prueba de autorización de un comprobante (obtención de CAE)"
wsfev1 = auth
Expand Down Expand Up @@ -131,14 +133,18 @@ def test_autorizar_comprobante(auth, tipo_cbte=1, cbte_nro=None, servicios=True)
wsfev1.CAESolicitar()

assert (wsfev1.Resultado== "A") # Aprobado!
assert isinstance(wsfev1.CAE, str)


assert isinstance(wsfev1.CAE,str)


assert (len(wsfev1.CAE)==len("63363178822329"))
assert (len(wsfev1.Vencimiento)==len("20130907"))
wsfev1.AnalizarXml("XmlResponse")
# observación "... no se encuentra registrado en los padrones de AFIP.":
#assertEqual(wsfev1.ObtenerTagXml("Obs", 0, "Code"), None)

@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7 or higher")

def test_consulta(auth):
"Prueba de obtener los datos de un comprobante autorizado"
wsfev1 = auth
Expand Down
14 changes: 10 additions & 4 deletions tests/test_wsfexv1.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import pytest
from pyafipws.wsaa import WSAA
from pyafipws.wsfexv1 import WSFEXv1
import future
from builtins import str

__author__ = "Mariano Reingart <reingart@gmail.com>"
__copyright__ = "Copyright (C) 2010-2019 Mariano Reingart"
Expand Down Expand Up @@ -151,7 +153,7 @@ def test_agregar_cbte_asoc(auth):
)
assert cbteasoc==True

@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7 or higher")

def test_autorizar(auth):
"""Test Autorizar Comprobante."""
wsfexv1 = auth
Expand All @@ -168,7 +170,10 @@ def test_autorizar(auth):
wsfexv1.GetCMP(tipo_cbte, punto_vta, cbte_nro)

assert (wsfexv1.Resultado == "A")
assert isinstance(wsfexv1.CAE, str)

assert isinstance(wsfexv1.CAE,str)


assert (wsfexv1.CAE)

#commented because wsfexv1.Vencimiento giving wrong expiration date
Expand Down Expand Up @@ -212,7 +217,7 @@ def test_recuperar_numero_transaccion(auth):
idx = wsfexv1.GetLastID()
# TODO: assertEqual(idy, idx)

@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7 or higher")

def test_parametros(auth):
"""Test de Parametros."""
wsfexv1 = auth
Expand All @@ -227,6 +232,7 @@ def test_parametros(auth):
assert (wsfexv1.GetParamIncoterms())
assert (wsfexv1.GetParamMonConCotizacion())
#assert (wsfexv1.GetParamPtosVenta())
assert isinstance(wsfexv1.GetParamCtz("DOL"), str)
assert isinstance(wsfexv1.GetParamCtz("DOL"),str)



2 changes: 1 addition & 1 deletion tests/test_wslsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def test_consultar_puntos_ventas(auth):
consulta = wslsp.ConsultarPuntosVentas()
assert consulta

@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7 or higher")

def test_mostrar_pdf(auth):
"""Test mostrar pdf."""
wslsp=auth
Expand Down
2 changes: 1 addition & 1 deletion tests/test_wsltv.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def test_consultar_puntos_ventas(auth):
consulta = wsltv.ConsultarPuntosVentas()
assert consulta

@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7 or higher")

def test_mostrar_pdf(auth):
"""Test mostrar PDF."""
wsltv=auth
Expand Down
14 changes: 9 additions & 5 deletions tests/test_wslum.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,15 @@ def test_consultar_puntos_ventas(auth):
consulta = wslum.ConsultarPuntosVentas()
assert consulta

@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7 or higher")

def test_mostrar_pdf(auth):
"""Test mostrar pdf."""
wslum=auth
archivo = "nota"
imprimir = False
pdf_ok = wslum.MostrarPDF(archivo, imprimir)
assert pdf_ok is False
pdf = wslum.GetParametro("pdf")
if pdf:
with open("liq.pdf", "wb") as f:
f.write(pdf)

show = wslum.MostrarPDF(archivo="liq.pdf", imprimir=True)

assert show is False
2 changes: 1 addition & 1 deletion tests/test_wsmtx.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def test_autorizar_comprobante(auth):
autorizado = wsmtx.AutorizarComprobante()
assert autorizado

@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7 or higher")

def test_cae_solicitar(auth):
"""Test de metodo opcional a AutorizarComprobante """
wsmtx = auth
Expand Down
1 change: 1 addition & 0 deletions wsaa.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"Módulo para obtener un ticket de autorización del web service WSAA de AFIP"
from __future__ import print_function
from __future__ import absolute_import
from __future__ import unicode_literals

# Basado en wsaa-client.php de Gerardo Fisanotti - DvSHyS/DiOPIN/AFIP - 13-apr-07
# Definir WSDL, CERT, PRIVATEKEY, PASSPHRASE, SERVICE, WSAAURL
Expand Down
2 changes: 1 addition & 1 deletion wsfexv1.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ def p_assert_eq(a, b):
wsdl = "https://wswhomo.afip.gov.ar/wsfexv1/service.asmx?WSDL"
cache = proxy = ""
wrapper = "httplib2"
cacert = open("conf/afip_ca_info.crt").read()
cacert = "conf/afip_ca_info.crt"
ok = wsfexv1.Conectar(cache, wsdl, proxy, wrapper, cacert)

if "--dummy" in sys.argv:
Expand Down
4 changes: 2 additions & 2 deletions wslsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
Ver wslsp.ini para parámetros de configuración (URL, certificados, etc.)"
"""

import os, sys, shelve
import os, sys, shelve, subprocess
import decimal, datetime
import traceback
import pprint
Expand Down Expand Up @@ -1033,7 +1033,7 @@ def ConsultarPuntosVentas(self, sep="||"):
def MostrarPDF(self, archivo, imprimir=False):
try:
if sys.platform == "linux2":
os.system("evince " "%s" "" % archivo)
subprocess.call(["evince", archivo])
else:
operation = imprimir and "print" or ""
os.startfile(archivo, operation)
Expand Down
4 changes: 2 additions & 2 deletions wsltv.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
Ver wsltv.ini para parámetros de configuración (URL, certificados, etc.)"
"""

import os, sys, shelve
import os, sys, shelve, subprocess
import decimal, datetime
import traceback
import pprint
Expand Down Expand Up @@ -844,7 +844,7 @@ def ConsultarPuntosVentas(self, sep="||"):
def MostrarPDF(self, archivo, imprimir=False):
try:
if sys.platform == "linux2":
os.system("evince " "%s" "" % archivo)
subprocess.call(["evince", archivo])
else:
operation = imprimir and "print" or ""
os.startfile(archivo, operation)
Expand Down
4 changes: 2 additions & 2 deletions wslum.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
Ver wslum.ini para parámetros de configuración (URL, certificados, etc.)"
"""

import os, sys, shelve
import os, sys, shelve, subprocess
import decimal, datetime
import traceback
import pprint
Expand Down Expand Up @@ -779,7 +779,7 @@ def ConsultarPuntosVentas(self, sep="||"):
def MostrarPDF(self, archivo, imprimir=False):
try:
if sys.platform == "linux2":
os.system("evince " "%s" "" % archivo)
subprocess.call(["evince", archivo])
else:
operation = imprimir and "print" or ""
os.startfile(archivo, operation)
Expand Down
8 changes: 4 additions & 4 deletions wsmtx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ def ConsultarComprobante(self, tipo_cbte, punto_vta, cbte_nro, reproceso=False):
"numeroDocumento": f["nro_doc"],
"numeroComprobante": f["cbt_desde"],
"numeroComprobante": f["cbt_hasta"],
"fechaEmision": f["fecha_cbte"],
"fechaEmision": f["fecha_cbte"].isoformat(),
"importeTotal": decimal.Decimal(str(f["imp_total"])),
"importeNoGravado": decimal.Decimal(str(f["imp_tot_conc"])),
"importeGravado": decimal.Decimal(str(f["imp_neto"])),
Expand All @@ -1165,9 +1165,9 @@ def ConsultarComprobante(self, tipo_cbte, punto_vta, cbte_nro, reproceso=False):
and decimal.Decimal(str(f["imp_trib"]))
or None,
"importeSubtotal": f["imp_subtotal"],
"fechaServicioDesde": f.get("fecha_serv_desde"),
"fechaServicioHasta": f.get("fecha_serv_hasta"),
"fechaVencimientoPago": f.get("fecha_venc_pago"),
"fechaServicioDesde": f.get("fecha_serv_desde").isoformat(),
"fechaServicioHasta": f.get("fecha_serv_hasta").isoformat(),
"fechaVencimientoPago": f.get("fecha_venc_pago").isoformat(),
"codigoMoneda": f["moneda_id"],
"cotizacionMoneda": str(decimal.Decimal(str(f["moneda_ctz"]))),
"arrayItems": [
Expand Down

0 comments on commit 3dfc2d1

Please sign in to comment.