41 lines
1.0 KiB
Python
41 lines
1.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Tests for bridge serial connect profile handling."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import asyncio
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(ROOT / "src"))
|
|
|
|
|
|
def test_connect_bridge_profile_serial(monkeypatch):
|
|
from util import bridge_runtime
|
|
|
|
calls = {}
|
|
|
|
async def fake_connect_serial(profile, settings):
|
|
calls["profile"] = profile
|
|
calls["settings"] = settings
|
|
return True, ""
|
|
|
|
monkeypatch.setattr(bridge_runtime, "connect_bridge_serial", fake_connect_serial)
|
|
|
|
class _Settings(dict):
|
|
def save(self):
|
|
pass
|
|
|
|
settings = _Settings({"bridge_serial_port": ""})
|
|
profile = {
|
|
"transport": "serial",
|
|
"serial_port": "/dev/ttyUSB0",
|
|
"serial_baudrate": 921600,
|
|
}
|
|
|
|
ok, err = asyncio.run(bridge_runtime.connect_bridge_profile(profile, settings))
|
|
assert ok is True
|
|
assert err == ""
|
|
assert calls["profile"]["serial_port"] == "/dev/ttyUSB0"
|