Files
overland-controller/tests/test_dashboard_source_contract.py
T

30 lines
1.1 KiB
Python

from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
DASHBOARD = ROOT / "firmware" / "esp32-s3-dashboard" / "esp32-s3-dashboard.ino"
def test_setup_done_button_event_is_handled():
source = DASHBOARD.read_text()
callback_start = source.index("static void setup_keyboard_event_cb")
callback_end = source.index("static void setup_textarea_event_cb", callback_start)
callback = source[callback_start:callback_end]
assert "LV_EVENT_CLICKED" in callback
assert "lv_obj_add_flag(setup_keyboard, LV_OBJ_FLAG_HIDDEN);" in callback
assert "lv_obj_add_event_cb(done_button, setup_keyboard_event_cb, LV_EVENT_CLICKED" in source
def test_dashboard_can_is_passive_and_logs_changed_frames():
source = DASHBOARD.read_text()
assert "TWAI_MODE_LISTEN_ONLY" in source
assert "twai_transmit(" not in source
assert "log_changed_can_frame(message);" in source
assert 'Serial.print("CAN,");' in source
assert 'can_serial_command.startsWith("TEMP,")' in source
assert 'can_serial_command.startsWith("MARK,")' in source
assert 'Serial.print("MARK,");' in source