feat: add a separate watch thumbnail gallery and logical device
Community checks / verify (push) Skipped
Verify Frame Flow / verify (push) Failing after 6m12s

This commit is contained in:
渡口浪人
2026-10-23 15:00:29 +08:00
parent 7178235022
commit 081d8b6ee0
12 changed files with 552 additions and 21 deletions
+66
View File
@@ -144,3 +144,69 @@ def test_upload_uses_selected_plan_or_skips(service, client, source, enabled):
assert result["wrist_thumbnail"]["plan_id"] == plan["id"]
else:
assert "wrist_thumbnail" not in result
def test_watch_gallery_separates_thumbnails_and_deletes_latest(client, service, source):
original = service.assets.put(b"fixture", "normal.jpg", "images")
generated = client.post(
"/api/v1/thumbnails/generate", json={**source, "plan": {"name": "Watch"}}
).json()
operation = service.submit(
"display",
{
"content": {"type": "photo_source", "source_id": "family"},
"options": {"priority": 0},
},
"living-room",
"test",
"request",
)
service.process_one()
auto = service.operation(operation)["result"]["wrist_thumbnail"]
page = client.get("/api/v1/thumbnails?limit=1").json()
assert page["total"] == 2 and len(page["items"]) == 1
items = client.get("/api/v1/thumbnails").json()["items"]
assert {x["asset_id"] for x in items} == {generated["asset_id"], auto["asset_id"]}
assert all(x["thumbnail"]["target_id"] == "watch" for x in items)
assert {x["asset_id"] for x in client.get("/api/v1/assets").json()} == {
original["asset_id"]
}
assert (
client.get("/api/v1/thumbnail-devices").json()[0]["transport_connected"]
is False
)
assert client.delete("/api/v1/assets/" + auto["asset_id"]).status_code == 204
assert client.get("/api/v1/thumbnails").json()["total"] == 1
assert (
service.db.one(
"SELECT payload FROM app_config WHERE key='wrist-thumbnail:living-room'"
)
is None
)
assert client.get(original["url"]).status_code == 200
def test_recover_legacy_receipt_does_not_guess_normal_images(service):
from pigway_frame_flow.display.thumbnail_gallery import recover
from pigway_frame_flow.storage.database import encode
thumbnail = service.assets.put(b"fixture", "watch.jpg", "cache")
normal = service.assets.put(b"fixture", "watch.jpg", "images")
service.db.execute(
"INSERT INTO app_config VALUES(?,?)",
(
"wrist-thumbnail:living-room",
encode({**thumbnail, "width": 410, "height": 502}),
),
)
recover(service)
recover(service)
assert service.db.one(
"SELECT payload FROM asset_sources WHERE asset_id=?", (thumbnail["asset_id"],)
)
assert (
service.db.one(
"SELECT payload FROM asset_sources WHERE asset_id=?", (normal["asset_id"],)
)
is None
)