29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
import pytest
|
|
from app.services.hardware_service import HardwareService, formatear_comando_hardware, calcular_checksum
|
|
|
|
|
|
def test_checksum_and_formatting():
|
|
assert calcular_checksum("\x0220O5") == "18"
|
|
assert formatear_comando_hardware(20, "O5") == "\x0220O518\x03"
|
|
assert formatear_comando_hardware(20, "T9") == "\x0220T90F\x03"
|
|
|
|
|
|
def test_encolar_apertura_virtual_module_molinete_club():
|
|
"""
|
|
Verifica que el Módulo Virtual 100004 (ENTRADA VISITAS):
|
|
1. Se resuelva a la placa física 100009 (Address 20).
|
|
2. Aplique payload O5 correspondiente a Molinete Club (tipo_acceso 7).
|
|
3. Genere la trama de apertura \x0220O518\x03.
|
|
4. Genere la trama T9 para impresión de ticket \x0220T90F\x03 cuando tipo_identificacion == 1.
|
|
"""
|
|
ok, res = HardwareService.encolar_apertura(modulo_id=100004, ticket_id=99999999)
|
|
assert ok is True
|
|
assert res["modulo_solicitado"] == 100004
|
|
assert res["modulo_fisico_target"] == 100009
|
|
assert res["address"] == 20
|
|
assert res["tipo_acceso"] == 7
|
|
assert res["is_pass"] is False
|
|
assert res["payload"] == "O5"
|
|
assert res["comando_trama"] == "\x0220O518\x03"
|
|
assert res["trama_ticket"] == "\x0220T90F\x03"
|