27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
from kota_tech.serialio.ports import PortInfo
|
|
|
|
|
|
def test_native_usb_port_identified_with_mac():
|
|
p = PortInfo("COM7", "USB Serial Device", 0x303A, 0x1001, "14:c1:9f:57:72:0c")
|
|
assert p.is_sensorbox
|
|
assert p.mac == "14:C1:9F:57:72:0C"
|
|
assert "Sensorbox (native USB)" in p.label and "14:C1:9F:57:72:0C" in p.label
|
|
|
|
|
|
def test_other_ports_not_sensorbox():
|
|
bt = PortInfo("COM3", "Standard Serial over Bluetooth link", None, None, None)
|
|
assert not bt.is_sensorbox and bt.mac is None
|
|
assert bt.label == "COM3 - Standard Serial over Bluetooth link"
|
|
|
|
|
|
def test_macos_lists_only_callout_devices(monkeypatch):
|
|
from types import SimpleNamespace
|
|
|
|
from kota_tech.serialio import ports
|
|
fake = [SimpleNamespace(device=d, description="USB JTAG/serial debug unit", vid=0x303A, pid=0x1001,
|
|
serial_number="A4:CB:8F:C9:46:F8")
|
|
for d in ("/dev/tty.usbmodem1101", "/dev/cu.usbmodem1101")]
|
|
monkeypatch.setattr(ports.sys, "platform", "darwin")
|
|
monkeypatch.setattr(ports.list_ports, "comports", lambda: fake)
|
|
assert [p.device for p in ports.list_serial_ports()] == ["/dev/cu.usbmodem1101"]
|