"""Host-only full KISS configuration tests; never open a serial device.""" from collections import deque from pathlib import Path import struct import sys from types import SimpleNamespace import unittest from unittest.mock import Mock, patch sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "tools/hil")) import ethernet_kiss_modem_probe as probe def fake_serial_modules(): serial = SimpleNamespace(Serial=Mock()) list_ports = SimpleNamespace(comports=Mock()) modules = {"serial": serial, "serial.tools": SimpleNamespace(list_ports=list_ports)} return serial, list_ports, modules def response(code, body=b""): return probe.encode_frame(6, bytes((code,)) + body) class Clock: def __init__(self): self.now = 0 def __call__(self): self.now += 0.01 return self.now class FakePort: def __init__(self): self.decoder = probe.Decoder() self.input = deque() self.writes = [] self.override = {} self.tx = 0 def write(self, data): for frame in self.decoder.feed(data): self.writes.append(frame) if frame[0] != 6: continue command = frame[1] body = {0x21: struct.pack("