feat(parity): implement Bloques 1, 2 y 3 complete feature parity v0.7.0-beta

This commit is contained in:
Carlos Tello
2026-10-29 20:52:58 -03:00
parent 918b87c645
commit ad92bb5fc1
28 changed files with 3704 additions and 118 deletions
+27 -27
View File
@@ -68,14 +68,14 @@ async def test_hardware_manual_open():
token = login_res.cookies.get("access_token")
res = await client.post(
"/api/v1/hardware/modules/100004/open",
json={"modulo_id": 100004, "motivo": "TEST_AUDIT"},
"/api/v1/hardware/modules/100009/open",
json={"modulo_id": 100009, "motivo": "TEST_AUDIT"},
cookies={"access_token": token},
)
assert res.status_code == 200
data = res.json()
assert data["status"] == "ok"
assert data["modulo_id"] == 100004
assert data["modulo_id"] == 100009
assert data["latencia_ms"] < 500.0
@@ -89,11 +89,12 @@ async def test_flujo_completo_ingreso_y_salida():
)
token = login_res.cookies.get("access_token")
doc_test = "99887766"
import time
doc_test = f"99{str(int(time.time()))[-6:]}"
# 1. Registro de Ingreso
entry_payload = {
"modulo_ingreso_id": 100004,
"modulo_ingreso_id": 100009,
"documento": doc_test,
"apellido": "TESTER",
"nombre": "INTEGRAL",
@@ -139,7 +140,7 @@ async def test_flujo_completo_ingreso_y_salida():
# 4. Registrar Salida
exit_payload = {
"ticket_id": ticket_id,
"modulo_salida_id": 100005,
"modulo_salida_id": 100010,
"patente_salida": "TST999",
"abrir_barrera": True,
}
@@ -167,7 +168,7 @@ async def test_flujo_completo_ingreso_y_salida():
cursor = conn.cursor()
cursor.execute("DELETE FROM PerDocCatVal WHERE Documento = %s", (doc_test,))
cursor.execute("DELETE FROM Per WHERE Apellido = 'TESTER'")
cursor.execute("DELETE FROM pdtmdl WHERE ModuloID IN (100004, 100005) AND Extra = %s", (str(ticket_id),))
cursor.execute("DELETE FROM pdtmdl WHERE ModuloID IN (100009, 100010) AND Extra = %s", (str(ticket_id),))
cursor.execute("DELETE FROM mvthist WHERE TicketID = %s", (ticket_id,))
cursor.execute("DELETE FROM tckhst WHERE TicketID = %s", (ticket_id,))
@@ -201,7 +202,7 @@ async def test_lot_permission_and_occupants_api():
entry_res = await client.post(
"/api/v1/access/entry",
json={
"modulo_ingreso_id": 100004,
"modulo_ingreso_id": 100009,
"documento": doc_cond,
"apellido": "GARCIA",
"nombre": "ROBERTO",
@@ -251,7 +252,7 @@ async def test_lot_permission_and_occupants_api():
"/api/v1/access/exit",
json={
"ticket_id": tid,
"modulo_salida_id": 100005,
"modulo_salida_id": 100010,
"patente_salida": "GRC888",
"abrir_barrera": False,
"personas_ids_permanecen": [pid_permanece] if pid_permanece else [],
@@ -289,7 +290,7 @@ async def test_validations_and_policies():
res_no_nombre = await client.post(
"/api/v1/access/entry",
json={
"modulo_ingreso_id": 100004,
"modulo_ingreso_id": 100009,
"documento": "11223344",
"nombre": "",
"lote_codigo": "100",
@@ -304,7 +305,7 @@ async def test_validations_and_policies():
res_no_lote = await client.post(
"/api/v1/access/entry",
json={
"modulo_ingreso_id": 100004,
"modulo_ingreso_id": 100009,
"documento": "11223344",
"nombre": "CARLOS",
"tipo_ingreso": "PEATON",
@@ -318,7 +319,7 @@ async def test_validations_and_policies():
res_no_patente = await client.post(
"/api/v1/access/entry",
json={
"modulo_ingreso_id": 100004,
"modulo_ingreso_id": 100009,
"documento": "11223344",
"nombre": "CARLOS",
"lote_codigo": "100",
@@ -334,7 +335,7 @@ async def test_validations_and_policies():
res_seguro_vencido = await client.post(
"/api/v1/access/entry",
json={
"modulo_ingreso_id": 100004,
"modulo_ingreso_id": 100009,
"documento": "11223344",
"nombre": "CARLOS",
"lote_codigo": "100",
@@ -351,7 +352,7 @@ async def test_validations_and_policies():
res_art_vencida = await client.post(
"/api/v1/access/entry",
json={
"modulo_ingreso_id": 100004,
"modulo_ingreso_id": 100009,
"documento": "11223344",
"nombre": "CARLOS",
"lote_codigo": "100",
@@ -392,11 +393,11 @@ async def test_verificaciones_peaton_vs_conductor_hardware_pulse(monkeypatch):
doc_bar = f"81{suffix}2"
doc_cnd = f"81{suffix}3"
# Caso 1: Peatón en Molinete Club (100004 -> tipo_acceso=7)
# Caso 1: Peatón en Molinete / Puerta Peatonal (100007 -> tipo_acceso=1)
res_peaton_molinete = await client.post(
"/api/v1/access/entry",
json={
"modulo_ingreso_id": 100004,
"modulo_ingreso_id": 100007,
"documento": doc_mol,
"nombre": "PEATON MOLINETE",
"lote_codigo": "100",
@@ -408,26 +409,25 @@ async def test_verificaciones_peaton_vs_conductor_hardware_pulse(monkeypatch):
assert res_peaton_molinete.status_code == 200
data_molinete = res_peaton_molinete.json()
assert data_molinete["barrier_opened"] is True
assert "molinete" in data_molinete["message"].lower() or "habilitado" in data_molinete["message"].lower()
assert "habilitado" in data_molinete["message"].lower() or "molinete" in data_molinete["message"].lower() or "puerta" in data_molinete["message"].lower()
# Egresar para no dejar ticket bloqueante
await client.post(
"/api/v1/access/exit",
json={
"ticket_id": data_molinete["ticket_id"],
"modulo_salida_id": 100005,
"modulo_salida_id": 100008,
"tipo_salida": "PEATON",
"abrir_barrera": True,
},
cookies={"access_token": token},
)
# Caso 2: Peatón en Barrera Vehicular (simulamos módulo tipo_acceso = 3: Barrera Estado)
monkeypatch.setattr(HardwareService, "obtener_tipo_acceso", lambda mod_id: 3)
# Caso 2: Peatón en Barrera Vehicular (100009 -> tipo_acceso=5)
res_peaton_barrera = await client.post(
"/api/v1/access/entry",
json={
"modulo_ingreso_id": 100004,
"modulo_ingreso_id": 100009,
"documento": doc_bar,
"nombre": "PEATON BARRERA",
"lote_codigo": "100",
@@ -447,7 +447,7 @@ async def test_verificaciones_peaton_vs_conductor_hardware_pulse(monkeypatch):
"/api/v1/access/exit",
json={
"ticket_id": data_barrera["ticket_id"],
"modulo_salida_id": 100005,
"modulo_salida_id": 100010,
"tipo_salida": "PEATON",
"abrir_barrera": True,
},
@@ -460,7 +460,7 @@ async def test_verificaciones_peaton_vs_conductor_hardware_pulse(monkeypatch):
res_conductor = await client.post(
"/api/v1/access/entry",
json={
"modulo_ingreso_id": 100004,
"modulo_ingreso_id": 100009,
"documento": doc_cnd,
"nombre": "CONDUCTOR BARRERA",
"lote_codigo": "100",
@@ -479,7 +479,7 @@ async def test_verificaciones_peaton_vs_conductor_hardware_pulse(monkeypatch):
"/api/v1/access/exit",
json={
"ticket_id": data_cond["ticket_id"],
"modulo_salida_id": 100005,
"modulo_salida_id": 100010,
"patente_salida": "ABC789",
"tipo_salida": "CONDUCTOR",
"abrir_barrera": True,
@@ -519,7 +519,7 @@ async def test_lote_residents_and_cacheo_garita():
res_sin_lote = await client.post(
"/api/v1/access/entry",
json={
"modulo_ingreso_id": 100004,
"modulo_ingreso_id": 100009,
"documento": "99112233",
"nombre": "SIN LOTE",
"tipo_ingreso": "PEATON",
@@ -537,7 +537,7 @@ async def test_lote_residents_and_cacheo_garita():
res_cch = await client.post(
"/api/v1/access/entry",
json={
"modulo_ingreso_id": 100004,
"modulo_ingreso_id": 100009,
"documento": doc_cch,
"apellido": "GARCIA",
"nombre": "IGNACIO",
@@ -566,7 +566,7 @@ async def test_lote_residents_and_cacheo_garita():
"/api/v1/access/exit",
json={
"ticket_id": tck_id,
"modulo_salida_id": 100005,
"modulo_salida_id": 100010,
"patente_salida": "CACH01",
"tipo_salida": "CONDUCTOR",
},