Skip to content

Commit b4a4518

Browse files
authored
Merge pull request #87 from chazuttu/coverage_receb1
Coverage receb1
2 parents 3a18835 + 9000cf8 commit b4a4518

File tree

11 files changed

+1810
-18
lines changed

11 files changed

+1810
-18
lines changed

.coveragerc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ omit =
55
*iibb*
66
*nsis*
77
*/padron.py
8-
*receb1*
9-
*formatos*
108
*recet*
119
*formatos*
1210
*rg3685*

receb1.py

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def autorizar(ws, entrada, salida):
198198
if DEBUG:
199199
print("\n".join(["%s='%s'" % (k, v) for k, v in list(ws.factura.items())]))
200200
print("id:", encabezado["id"])
201-
if not DEBUG or input("Facturar?") == "S":
201+
if not DEBUG :
202202
cae = ws.Authorize(encabezado["id"])
203203
dic = ws.factura
204204
dic.update(
@@ -248,12 +248,12 @@ def depurar_xml(client):
248248
f.write(client.xml_request)
249249
f.close()
250250
f = open("response-%s.xml" % fecha, "w")
251-
f.write(client.xml_response)
251+
f.write(client.xml_response.decode())
252252
f.close()
253253

254254

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

279279
if "/debug" in sys.argv:
280280
DEBUG = True
@@ -290,7 +290,7 @@ def main():
290290
if config.has_option("WSAA", "URL") and not HOMO:
291291
wsaa_url = config.get("WSAA", "URL")
292292
else:
293-
wsaa_url = wsaa.WSAAURL
293+
wsaa_url = None
294294
if config.has_option("WSBFE", "URL") and not HOMO:
295295
wsbfe_url = config.get("WSBFE", "URL")
296296
else:
@@ -320,7 +320,7 @@ def main():
320320
if "/dummy" in sys.argv:
321321
print("Consultando estado de servidores...")
322322
print(ws.Dummy())
323-
sys.exit(0)
323+
return
324324

325325
if "/formato" in sys.argv:
326326
print("Formato:")
@@ -333,7 +333,7 @@ def main():
333333
% (clave, comienzo, longitud, tipo)
334334
)
335335
comienzo += longitud
336-
sys.exit(0)
336+
return
337337

338338
# obteniendo el TA
339339
from .wsaa import WSAA
@@ -393,25 +393,36 @@ def main():
393393

394394
if "/ult" in sys.argv:
395395
print("Consultar ultimo numero:")
396-
tipo_cbte = int(input("Tipo de comprobante: "))
397-
punto_vta = int(input("Punto de venta: "))
396+
i = sys.argv.index("/ult")
397+
if i + 2 < len(sys.argv):
398+
tipo_cbte = int(sys.argv[i + 1])
399+
punto_vta = int(sys.argv[i + 2])
400+
else:
401+
tipo_cbte = int(input("Tipo de comprobante: "))
402+
punto_vta = int(input("Punto de venta: "))
398403
ult_cbte = ws.GetLastCMP(tipo_cbte, punto_vta)
399404
print("Ultimo numero: ", ult_cbte)
400405
print("Fecha: ", ws.FechaCbte)
401406
depurar_xml(ws.client)
402-
sys.exit(0)
407+
return
403408

404409
if "/id" in sys.argv:
405410
ult_id = ws.GetLastID()
406411
print("ID: ", ult_id)
407412
depurar_xml(ws.client)
408-
sys.exit(0)
413+
return
409414

410415
if "/get" in sys.argv:
411416
print("Recuperar comprobante:")
412-
tipo_cbte = int(input("Tipo de comprobante: "))
413-
punto_vta = int(input("Punto de venta: "))
414-
cbte_nro = int(input("Numero de comprobante: "))
417+
i = sys.argv.index("/get")
418+
if i + 3 < len(sys.argv):
419+
tipo_cbte = int(sys.argv[i + 1])
420+
punto_vta = int(sys.argv[i + 2])
421+
cbte_nro = int(sys.argv[i + 3])
422+
else:
423+
tipo_cbte = int(input("Tipo de comprobante: "))
424+
punto_vta = int(input("Punto de venta: "))
425+
cbte_nro = int(input("Numero de comprobante: "))
415426
cae = ws.GetCMP(tipo_cbte, punto_vta, cbte_nro)
416427
cbt = {
417428
"fecha_cbte": ws.FechaCbte,
@@ -427,7 +438,7 @@ def main():
427438
for k, v in list(cbt.items()):
428439
print("%s = %s" % (k, v))
429440
depurar_xml(ws.client)
430-
sys.exit(0)
441+
return
431442

432443
f_entrada = f_salida = None
433444
try:
@@ -445,7 +456,7 @@ def main():
445456
f_salida.close()
446457
if XML:
447458
depurar_xml(ws.client)
448-
sys.exit(0)
459+
return
449460

450461
except Exception as e:
451462
print(str(e).encode("ascii", "ignore"))

tests/cassettes/test_wsbfev1_receb1/test_main_ayuda.yaml

Lines changed: 683 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
interactions:
2+
- request:
3+
body: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
4+
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n<soap:Header/>\n<soap:Body>\n
5+
\ \n</soap:Body>\n</soap:Envelope>"
6+
headers:
7+
accept-encoding:
8+
- gzip, deflate
9+
content-length:
10+
- '269'
11+
content-type:
12+
- text/xml; charset="UTF-8"
13+
soapaction:
14+
- '"http://ar.gov.afip.dif.bfev1/BFEDummy"'
15+
user-agent:
16+
- Mozilla/5.0 (Windows NT 6.1; Win64; x64)
17+
method: POST
18+
uri: https://wswhomo.afip.gov.ar/wsbfev1/service.asmx
19+
response:
20+
body:
21+
string: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
22+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Header><FEHeaderInfo
23+
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
24+
xmlns="http://ar.gov.afip.dif.bfev1/"><BFEDummyResult><AppServer>OK</AppServer><DbServer>OK</DbServer><AuthServer>OK</AuthServer></BFEDummyResult></BFEDummyResponse></soap:Body></soap:Envelope>
25+
headers:
26+
Cache-Control:
27+
- private, max-age=0
28+
Content-Length:
29+
- '624'
30+
Content-Type:
31+
- text/xml; charset=utf-8
32+
Date:
33+
- Sun, 01 Aug 2021 20:48:12 GMT
34+
Expect-CT:
35+
- enforce
36+
MicrosoftOfficeWebServer:
37+
- 5.0_Pub
38+
Set-Cookie:
39+
- TS01983a04=01439f1ddf6f5f561f02c6ba1758b5bbe617e236e1b2d38af042e3d72c3257575a90a292a0;
40+
Path=/
41+
Strict-Transport-Security:
42+
- nosniff
43+
X-AspNet-Version:
44+
- 2.0.50727
45+
X-Content-Type-Options:
46+
- nosniff
47+
X-Frame-Options:
48+
- SAMEORIGIN
49+
X-Powered-By:
50+
- ASP.NET
51+
X-Xss-Protection:
52+
- 1; mode=block
53+
status:
54+
code: 200
55+
message: OK
56+
version: 1

0 commit comments

Comments
 (0)