feat: add a separate watch thumbnail gallery and logical device
This commit is contained in:
@@ -1616,5 +1616,37 @@
|
||||
"502",
|
||||
"503"
|
||||
]
|
||||
},
|
||||
"/api/v1/thumbnail-devices": {
|
||||
"get": [
|
||||
"200",
|
||||
"400",
|
||||
"401",
|
||||
"403",
|
||||
"404",
|
||||
"409",
|
||||
"413",
|
||||
"422",
|
||||
"429",
|
||||
"500",
|
||||
"502",
|
||||
"503"
|
||||
]
|
||||
},
|
||||
"/api/v1/thumbnails": {
|
||||
"get": [
|
||||
"200",
|
||||
"400",
|
||||
"401",
|
||||
"403",
|
||||
"404",
|
||||
"409",
|
||||
"413",
|
||||
"422",
|
||||
"429",
|
||||
"500",
|
||||
"502",
|
||||
"503"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -453,7 +453,8 @@ def test_settings_exposes_storage_display_name(client, service):
|
||||
result = client.get("/api/v1/settings").json()
|
||||
assert result["storage_name"] == "Family NAS"
|
||||
destinations = {d["id"]: d for d in result["gallery_destinations"]}
|
||||
assert set(destinations) == {"cloud", "local"}
|
||||
assert set(destinations) == {"cloud", "local", "watch"}
|
||||
assert destinations["watch"]["adapter"] == "watch-thumbnails"
|
||||
assert destinations["cloud"]["name"] == "KoKonna"
|
||||
assert destinations["local"]["name"] == "Family NAS"
|
||||
assert all(d["connected"] and d["supports_upload"] for d in destinations.values())
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user