fix(camera-parity-pwa): resolver parpadeo de camara, paridad funcional de acompanantes, lotes, egreso y PWA responsive
This commit is contained in:
@@ -170,3 +170,105 @@ async def test_flujo_completo_ingreso_y_salida():
|
||||
cursor.execute("DELETE FROM pdtmdl WHERE ModuloID IN (100004, 100005) 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,))
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_lot_permission_and_occupants_api():
|
||||
transport = ASGITransport(app=app)
|
||||
async with AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
login_res = await client.post(
|
||||
"/api/v1/auth/login",
|
||||
json={"username": "guardia", "password": "guardia"},
|
||||
)
|
||||
token = login_res.cookies.get("access_token")
|
||||
|
||||
# 1. Validar permiso de lote
|
||||
lot_res = await client.get(
|
||||
"/api/v1/access/lots/1/permission",
|
||||
cookies={"access_token": token},
|
||||
)
|
||||
assert lot_res.status_code == 200
|
||||
lot_data = lot_res.json()
|
||||
assert "estado" in lot_data
|
||||
assert "color" in lot_data
|
||||
assert "detalle" in lot_data
|
||||
|
||||
# 2. Registrar ingreso con acompañantes
|
||||
doc_cond = "88112233"
|
||||
doc_acomp1 = "88112234"
|
||||
doc_acomp2 = "88112235"
|
||||
|
||||
entry_res = await client.post(
|
||||
"/api/v1/access/entry",
|
||||
json={
|
||||
"modulo_ingreso_id": 100004,
|
||||
"documento": doc_cond,
|
||||
"apellido": "GARCIA",
|
||||
"nombre": "ROBERTO",
|
||||
"patente": "GRC888",
|
||||
"cantidad_ocupantes": 3,
|
||||
"abrir_barrera": False,
|
||||
"integrantes": [
|
||||
{
|
||||
"documento": doc_acomp1,
|
||||
"apellido": "GARCIA",
|
||||
"nombre": "ANA",
|
||||
"sexo": "F",
|
||||
"es_menor": False,
|
||||
"rol_id": 2,
|
||||
},
|
||||
{
|
||||
"documento": doc_acomp2,
|
||||
"apellido": "GARCIA",
|
||||
"nombre": "LUCAS",
|
||||
"sexo": "M",
|
||||
"es_menor": True,
|
||||
"rol_id": 3,
|
||||
},
|
||||
],
|
||||
},
|
||||
cookies={"access_token": token},
|
||||
)
|
||||
assert entry_res.status_code == 200
|
||||
tid = entry_res.json()["ticket_id"]
|
||||
|
||||
# 3. Consultar ocupantes del ticket
|
||||
occ_res = await client.get(
|
||||
f"/api/v1/access/tickets/{tid}/occupants",
|
||||
cookies={"access_token": token},
|
||||
)
|
||||
assert occ_res.status_code == 200
|
||||
ocupantes = occ_res.json()
|
||||
assert len(ocupantes) >= 2
|
||||
docs_cargados = [o["documento"] for o in ocupantes]
|
||||
assert doc_cond in docs_cargados
|
||||
|
||||
# 4. Registrar salida verificando al conductor y desacoplando al acompañante que permanece
|
||||
pid_permanece = next((o["persona_id"] for o in ocupantes if o["documento"] == doc_acomp1), 0)
|
||||
|
||||
exit_res = await client.post(
|
||||
"/api/v1/access/exit",
|
||||
json={
|
||||
"ticket_id": tid,
|
||||
"modulo_salida_id": 100005,
|
||||
"patente_salida": "GRC888",
|
||||
"abrir_barrera": False,
|
||||
"personas_ids_permanecen": [pid_permanece] if pid_permanece else [],
|
||||
"integrantes_verificados": [],
|
||||
},
|
||||
cookies={"access_token": token},
|
||||
)
|
||||
assert exit_res.status_code == 200
|
||||
assert exit_res.json()["status"] == "ok"
|
||||
|
||||
# Limpieza
|
||||
from app.core.database import db_session
|
||||
with db_session() as conn:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("DELETE FROM PerDocCatVal WHERE Documento IN (%s, %s, %s)", (doc_cond, doc_acomp1, doc_acomp2))
|
||||
cursor.execute("DELETE FROM Per WHERE Apellido = 'GARCIA'")
|
||||
cursor.execute("DELETE FROM mvthist WHERE TicketID = %s", (tid,))
|
||||
cursor.execute("DELETE FROM tckhst WHERE TicketID = %s", (tid,))
|
||||
cursor.execute("DELETE FROM tckper WHERE TicketID = %s", (tid,))
|
||||
cursor.execute("DELETE FROM tck WHERE TicketID = %s", (tid,))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user