Firmware build check / build-check (push) Successful in 5m37s
Build and release firmware / build-and-release (push) Successful in 5m36s
Build and push server image / test (push) Successful in 1m37s
Build and push server image / build-and-push (push) Successful in 4m18s
Build and push server image / deploy (push) Failing after 1m20s
Server: migration 41 drops the pre-widget-system Frame columns (mode/album_id/current_asset_id/queue/calendar_*/whiteboard_*, etc) docs/widgets.md flagged as the deliberately-deferred Phase 6 cleanup, with a raw-SQL backfill safety net for any frame that still somehow lacks a Widget. Also drops legacy_token_enabled and the shared MANAGEMENT_TOKEN fallback it gated in require_device/require_browser -- the per-frame manage_token/device_token flow (and the /m/ page) fully supersede it now; MANAGEMENT_TOKEN's only remaining role is the optional pre-setup claim gate. Confirmed with the maintainer that the deployed frame is already off the shared token before removing the server-side fallback. Firmware: the captive portal's "Access Token" field and its NVS/ build_url plumbing only ever mattered for pointing new firmware at an old pre-multi-frame server -- gone along with the server-side fallback it fed. Version bump to publish the change.
97 lines
3.4 KiB
Python
97 lines
3.4 KiB
Python
"""GET /api/frames/{id}/now-displaying -- the frozen half of the header
|
|
preview pair (see routers/device.py's _record_last_displayed). Distinct
|
|
from /preview (test_frame_preview.py): that one always live-renders,
|
|
this one serves back exactly whatever bytes a device-facing endpoint
|
|
last actually sent, recorded as a side effect of /frame/image,
|
|
/frame/advance, and /frame/back."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import io
|
|
|
|
from PIL import Image
|
|
|
|
from app.image_pipeline import logical_render_size
|
|
from app.models import Frame
|
|
|
|
from .conftest import claim_device, link_user, login, make_user
|
|
|
|
|
|
def test_now_displaying_404s_before_any_device_fetch(client, db_session):
|
|
client.post("/setup", data={"username": "alice", "password": "hunter22"})
|
|
|
|
resp = client.get("/api/frames/1/now-displaying")
|
|
assert resp.status_code == 404
|
|
|
|
|
|
def test_frame_image_records_now_displaying(client, db_session):
|
|
client.post("/setup", data={"username": "alice", "password": "hunter22"})
|
|
frame = db_session.get(Frame, 1)
|
|
creds = claim_device(db_session, frame)
|
|
|
|
resp = client.get(f"/frame/image?{creds}")
|
|
assert resp.status_code == 200
|
|
|
|
resp = client.get("/api/frames/1/now-displaying")
|
|
assert resp.status_code == 200
|
|
assert resp.headers["content-type"] == "image/png"
|
|
assert "X-Displayed-At" in resp.headers
|
|
assert float(resp.headers["X-Displayed-At"]) > 0
|
|
|
|
img = Image.open(io.BytesIO(resp.content))
|
|
assert img.size == logical_render_size(frame.orientation)
|
|
|
|
|
|
def test_advance_and_back_also_update_now_displaying(client, db_session):
|
|
client.post("/setup", data={"username": "alice", "password": "hunter22"})
|
|
creds = claim_device(db_session, db_session.get(Frame, 1))
|
|
|
|
client.get(f"/frame/image?{creds}")
|
|
first = client.get("/api/frames/1/now-displaying")
|
|
assert first.status_code == 200
|
|
|
|
resp = client.post(f"/frame/advance?{creds}")
|
|
assert resp.status_code == 200
|
|
after_advance = client.get("/api/frames/1/now-displaying")
|
|
assert after_advance.status_code == 200
|
|
|
|
resp = client.post(f"/frame/back?{creds}")
|
|
assert resp.status_code == 200
|
|
after_back = client.get("/api/frames/1/now-displaying")
|
|
assert after_back.status_code == 200
|
|
assert float(after_back.headers["X-Displayed-At"]) >= float(first.headers["X-Displayed-At"])
|
|
|
|
|
|
def test_now_displaying_visible_to_linked_user(client, db_session):
|
|
client.post("/setup", data={"username": "alice", "password": "hunter22"})
|
|
bob = make_user(db_session, "bob")
|
|
frame = db_session.get(Frame, 1)
|
|
link_user(db_session, bob, frame)
|
|
creds = claim_device(db_session, frame)
|
|
client.get(f"/frame/image?{creds}")
|
|
|
|
client.cookies.clear()
|
|
login(client, "bob")
|
|
resp = client.get("/api/frames/1/now-displaying")
|
|
assert resp.status_code == 200
|
|
|
|
|
|
def test_now_displaying_hidden_from_unrelated_user(client, db_session):
|
|
client.post("/setup", data={"username": "alice", "password": "hunter22"})
|
|
make_user(db_session, "mallory")
|
|
client.get("/frame/image")
|
|
|
|
client.cookies.clear()
|
|
login(client, "mallory")
|
|
resp = client.get("/api/frames/1/now-displaying")
|
|
assert resp.status_code == 404
|
|
|
|
|
|
def test_now_displaying_requires_login(client, db_session):
|
|
client.post("/setup", data={"username": "alice", "password": "hunter22"})
|
|
client.get("/frame/image")
|
|
|
|
client.cookies.clear()
|
|
resp = client.get("/api/frames/1/now-displaying")
|
|
assert resp.status_code in (401, 403)
|