Files
espresso_frame/server/tests/test_board_panel_mapping.py
T
tfaour 474b92a282
Build and push server image / test (push) Successful in 45s
Firmware build check / build-check (push) Successful in 2m50s
Build and push server image / build-and-push (push) Successful in 4m36s
Build and push server image / deploy (push) Failing after 1m34s
Add server-side support for a second panel (13.3in Spectra 6 / EE02) and scaffold its firmware target
Server: Frame.panel_type (new column + migration) is auto-derived from
the device's reported board (X-Frame-Board), never user-set -- the
panel is a property of the hardware, not a picker in the UI.
image_pipeline's packing/render pipeline is parameterized by panel
geometry instead of hardcoded 800x480 globals, with the real confirmed
13.3in geometry (1600x1200) registered alongside the original 7.3in
panel. Existing 7.3in frames are unaffected (column default + board
mapping both resolve to the original panel).

Board identifiers are also renamed (devkit/xiao -> devkit_esp32c6/
xiao_esp32c6, plus new "ee02") since the EE02 board also carries a XIAO
module -- "xiao" alone stopped disambiguating hardware. The server
keeps accepting the legacy bare names indefinitely for already-flashed
devices.

Firmware: scaffolds a third build target (ee02, ESP32-S3 -- a real
chip-target change, not just a same-chip Kconfig variant like xiao) and
a new epd13in3e driver component skeleton. The actual panel init/LUT/
refresh register sequence isn't ported from vendor demo code yet (none
was available), so that component deliberately fails to compile
(#error) rather than risk sending unverified register values to real
hardware -- devkit/xiao are unaffected and build identically to before.
CI's ee02 build step is continue-on-error for the same reason.
2026-08-04 20:08:22 +00:00

81 lines
2.9 KiB
Python

"""GET /frame/config auto-deriving Frame.panel_type from the device's
self-reported board (X-Frame-Board header) -- see routers/device.py's
BOARD_PANEL_MAP. Panel type is a property of the hardware, never a user
setting, so this mapping is the only thing that's allowed to change it."""
from __future__ import annotations
from app.models import Frame
from .conftest import claim_device
def test_new_chip_qualified_board_names_map_to_the_right_panel(client, db_session):
frame = db_session.get(Frame, 1)
creds = claim_device(db_session, frame)
resp = client.get(f"/frame/config?{creds}", headers={"X-Frame-Board": "ee02"})
assert resp.status_code == 200
db_session.refresh(frame)
assert frame.device_board_variant == "ee02"
assert frame.panel_type == "epd13in3e"
def test_legacy_bare_board_names_still_map_correctly(client, db_session):
"""Already-flashed devices that haven't been OTA'd past the
devkit/xiao -> devkit_esp32c6/xiao_esp32c6 rename must keep reporting
their old bare name and still get mapped to the right panel -- fielded
firmware can't be retroactively renamed."""
frame = db_session.get(Frame, 1)
creds = claim_device(db_session, frame)
resp = client.get(f"/frame/config?{creds}", headers={"X-Frame-Board": "xiao"})
assert resp.status_code == 200
db_session.refresh(frame)
assert frame.device_board_variant == "xiao"
assert frame.panel_type == "epd7in3e"
def test_renamed_chip_qualified_board_names_map_correctly(client, db_session):
frame = db_session.get(Frame, 1)
creds = claim_device(db_session, frame)
resp = client.get(f"/frame/config?{creds}", headers={"X-Frame-Board": "devkit_esp32c6"})
assert resp.status_code == 200
db_session.refresh(frame)
assert frame.device_board_variant == "devkit_esp32c6"
assert frame.panel_type == "epd7in3e"
def test_unrecognized_board_name_leaves_panel_type_unchanged(client, db_session):
"""An unrecognized board string still gets recorded (same as today's
device_board_variant behavior) but must never blow away whatever
panel_type is already set -- an unknown value is more likely a typo
or a not-yet-supported board than evidence the frame's actual panel
changed."""
frame = db_session.get(Frame, 1)
frame.panel_type = "epd13in3e"
db_session.commit()
creds = claim_device(db_session, frame)
resp = client.get(f"/frame/config?{creds}", headers={"X-Frame-Board": "some_future_board"})
assert resp.status_code == 200
db_session.refresh(frame)
assert frame.device_board_variant == "some_future_board"
assert frame.panel_type == "epd13in3e"
def test_no_board_header_leaves_panel_type_at_its_default(client, db_session):
frame = db_session.get(Frame, 1)
creds = claim_device(db_session, frame)
resp = client.get(f"/frame/config?{creds}")
assert resp.status_code == 200
db_session.refresh(frame)
assert frame.panel_type == "epd7in3e"