Skip to content

Commit

Permalink
Merge pull request #87 from chazuttu/coverage_receb1
Browse files Browse the repository at this point in the history
Coverage receb1
  • Loading branch information
reingart authored Mar 24, 2022
2 parents 3a18835 + 9000cf8 commit b4a4518
Show file tree
Hide file tree
Showing 11 changed files with 1,810 additions and 18 deletions.
2 changes: 0 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ omit =
*iibb*
*nsis*
*/padron.py
*receb1*
*formatos*
*recet*
*formatos*
*rg3685*
Expand Down
43 changes: 27 additions & 16 deletions receb1.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def autorizar(ws, entrada, salida):
if DEBUG:
print("\n".join(["%s='%s'" % (k, v) for k, v in list(ws.factura.items())]))
print("id:", encabezado["id"])
if not DEBUG or input("Facturar?") == "S":
if not DEBUG :
cae = ws.Authorize(encabezado["id"])
dic = ws.factura
dic.update(
Expand Down Expand Up @@ -248,12 +248,12 @@ def depurar_xml(client):
f.write(client.xml_request)
f.close()
f = open("response-%s.xml" % fecha, "w")
f.write(client.xml_response)
f.write(client.xml_response.decode())
f.close()


def main():
global HOMO, DEBUG, XML, CONFIG_FILE
global HOMO, DEBUG, XML, CONFIG_FILE, wsaa
if "/ayuda" in sys.argv:
print(LICENCIA)
print()
Expand All @@ -274,7 +274,7 @@ def main():
print(" /dbf: lee y almacena la información en tablas DBF")
print()
print("Ver rece.ini para parámetros de configuración (URL, certificados, etc.)")
sys.exit(0)
return

if "/debug" in sys.argv:
DEBUG = True
Expand All @@ -290,7 +290,7 @@ def main():
if config.has_option("WSAA", "URL") and not HOMO:
wsaa_url = config.get("WSAA", "URL")
else:
wsaa_url = wsaa.WSAAURL
wsaa_url = None
if config.has_option("WSBFE", "URL") and not HOMO:
wsbfe_url = config.get("WSBFE", "URL")
else:
Expand Down Expand Up @@ -320,7 +320,7 @@ def main():
if "/dummy" in sys.argv:
print("Consultando estado de servidores...")
print(ws.Dummy())
sys.exit(0)
return

if "/formato" in sys.argv:
print("Formato:")
Expand All @@ -333,7 +333,7 @@ def main():
% (clave, comienzo, longitud, tipo)
)
comienzo += longitud
sys.exit(0)
return

# obteniendo el TA
from .wsaa import WSAA
Expand Down Expand Up @@ -393,25 +393,36 @@ def main():

if "/ult" in sys.argv:
print("Consultar ultimo numero:")
tipo_cbte = int(input("Tipo de comprobante: "))
punto_vta = int(input("Punto de venta: "))
i = sys.argv.index("/ult")
if i + 2 < len(sys.argv):
tipo_cbte = int(sys.argv[i + 1])
punto_vta = int(sys.argv[i + 2])
else:
tipo_cbte = int(input("Tipo de comprobante: "))
punto_vta = int(input("Punto de venta: "))
ult_cbte = ws.GetLastCMP(tipo_cbte, punto_vta)
print("Ultimo numero: ", ult_cbte)
print("Fecha: ", ws.FechaCbte)
depurar_xml(ws.client)
sys.exit(0)
return

if "/id" in sys.argv:
ult_id = ws.GetLastID()
print("ID: ", ult_id)
depurar_xml(ws.client)
sys.exit(0)
return

if "/get" in sys.argv:
print("Recuperar comprobante:")
tipo_cbte = int(input("Tipo de comprobante: "))
punto_vta = int(input("Punto de venta: "))
cbte_nro = int(input("Numero de comprobante: "))
i = sys.argv.index("/get")
if i + 3 < len(sys.argv):
tipo_cbte = int(sys.argv[i + 1])
punto_vta = int(sys.argv[i + 2])
cbte_nro = int(sys.argv[i + 3])
else:
tipo_cbte = int(input("Tipo de comprobante: "))
punto_vta = int(input("Punto de venta: "))
cbte_nro = int(input("Numero de comprobante: "))
cae = ws.GetCMP(tipo_cbte, punto_vta, cbte_nro)
cbt = {
"fecha_cbte": ws.FechaCbte,
Expand All @@ -427,7 +438,7 @@ def main():
for k, v in list(cbt.items()):
print("%s = %s" % (k, v))
depurar_xml(ws.client)
sys.exit(0)
return

f_entrada = f_salida = None
try:
Expand All @@ -445,7 +456,7 @@ def main():
f_salida.close()
if XML:
depurar_xml(ws.client)
sys.exit(0)
return

except Exception as e:
print(str(e).encode("ascii", "ignore"))
Expand Down
683 changes: 683 additions & 0 deletions tests/cassettes/test_wsbfev1_receb1/test_main_ayuda.yaml

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions tests/cassettes/test_wsbfev1_receb1/test_main_dummy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
interactions:
- request:
body: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n<soap:Header/>\n<soap:Body>\n
\ \n</soap:Body>\n</soap:Envelope>"
headers:
accept-encoding:
- gzip, deflate
content-length:
- '269'
content-type:
- text/xml; charset="UTF-8"
soapaction:
- '"http://ar.gov.afip.dif.bfev1/BFEDummy"'
user-agent:
- Mozilla/5.0 (Windows NT 6.1; Win64; x64)
method: POST
uri: https://wswhomo.afip.gov.ar/wsbfev1/service.asmx
response:
body:
string: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Header><FEHeaderInfo
xmlns="http://ar.gov.afip.dif.bfev1/"><ambiente>Homologacion - efa</ambiente><fecha>2021-08-01T17:48:12.94082-03:00</fecha><id>1.7.0.0</id></FEHeaderInfo></soap:Header><soap:Body><BFEDummyResponse
xmlns="http://ar.gov.afip.dif.bfev1/"><BFEDummyResult><AppServer>OK</AppServer><DbServer>OK</DbServer><AuthServer>OK</AuthServer></BFEDummyResult></BFEDummyResponse></soap:Body></soap:Envelope>
headers:
Cache-Control:
- private, max-age=0
Content-Length:
- '624'
Content-Type:
- text/xml; charset=utf-8
Date:
- Sun, 01 Aug 2021 20:48:12 GMT
Expect-CT:
- enforce
MicrosoftOfficeWebServer:
- 5.0_Pub
Set-Cookie:
- TS01983a04=01439f1ddf6f5f561f02c6ba1758b5bbe617e236e1b2d38af042e3d72c3257575a90a292a0;
Path=/
Strict-Transport-Security:
- nosniff
X-AspNet-Version:
- 2.0.50727
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- SAMEORIGIN
X-Powered-By:
- ASP.NET
X-Xss-Protection:
- 1; mode=block
status:
code: 200
message: OK
version: 1
Loading

0 comments on commit b4a4518

Please sign in to comment.