fix: recognize displayed terminal versions and clean obsolete gallery remnants
This commit is contained in:
@@ -179,6 +179,7 @@ def test_pipeline_selects_once_for_frame_and_watch_and_shared_plan(
|
||||
def unavailable_frame(*args, **kwargs):
|
||||
raise AssertionError("Source generation must not read a frame device")
|
||||
|
||||
original_device = service.registry.get("living-room").device
|
||||
monkeypatch.setattr(
|
||||
service.registry.get("living-room"), "device", unavailable_frame
|
||||
)
|
||||
@@ -196,6 +197,7 @@ def test_pipeline_selects_once_for_frame_and_watch_and_shared_plan(
|
||||
assert len(calls) == 1
|
||||
assert len(result["outputs"]) == 3
|
||||
assert len({v["asset_id"] for v in result["outputs"]}) == 2
|
||||
monkeypatch.setattr(service.registry.get("living-room"), "device", original_device)
|
||||
for terminal in ["living-room", "watch"]:
|
||||
page = client.get("/api/v1/library-terminals/" + terminal + "/images").json()
|
||||
assert page["total"] == 1
|
||||
@@ -402,6 +404,7 @@ def test_successful_scheduled_frame_delivery_retains_job_provenance(
|
||||
service.sync()
|
||||
page = client.get("/api/v1/library-terminals/living-room/images").json()
|
||||
assert page["items"][0]["delivery_status"] == "COMPLETED"
|
||||
assert page["items"][0]["current"] is True
|
||||
from pigway_frame_flow.storage.database import encode, now_iso
|
||||
|
||||
token = "library-reader-test"
|
||||
@@ -647,3 +650,45 @@ def test_single_source_migration_preserves_timing_and_generates_without_device_w
|
||||
assert service.db.one("SELECT COUNT(*) AS n FROM source_images")["n"] == 1
|
||||
assert service.db.one("SELECT COUNT(*) AS n FROM library_versions")["n"] == 2
|
||||
assert migrate(call, apply=True)["already_configured"]
|
||||
|
||||
|
||||
def test_terminal_current_picture_uses_synced_live_asset(
|
||||
client, service, library_source, monkeypatch
|
||||
):
|
||||
from pigway_frame_flow.errors import ErrorCode, FlowError
|
||||
|
||||
plan = create_plan(client, name="Frame", width=1200, height=1600)
|
||||
bind(client, "living-room", "family", plan)
|
||||
picture = import_picture(client)
|
||||
version = client.post(
|
||||
"/api/v1/source-images/" + picture["id"] + "/generate", json={}
|
||||
).json()[0]
|
||||
current = {"synced": True, "source_known": True, "asset_id": version["asset_id"]}
|
||||
monkeypatch.setattr(service, "current_content", lambda _, **kwargs: current)
|
||||
endpoint = "/api/v1/library-terminals/living-room/images"
|
||||
assert client.get(endpoint).json()["items"][0]["current"] is True
|
||||
current["asset_id"] = "another-picture"
|
||||
assert client.get(endpoint).json()["items"][0]["current"] is False
|
||||
current.update(asset_id=version["asset_id"], synced=False)
|
||||
assert client.get(endpoint).json()["items"][0]["current"] is False
|
||||
current.update(synced=True, source_known=False)
|
||||
assert client.get(endpoint).json()["items"][0]["current"] is False
|
||||
|
||||
def offline(_, **kwargs):
|
||||
raise FlowError(ErrorCode.CLOUD_UNAVAILABLE, "Offline", 502)
|
||||
|
||||
monkeypatch.setattr(service, "current_content", offline)
|
||||
page = client.get(endpoint)
|
||||
assert page.status_code == 200 and page.json()["items"][0]["current"] is False
|
||||
|
||||
driver = service.registry.get("living-room")
|
||||
offline_device = driver.device().model_copy(update={"status": "offline"})
|
||||
monkeypatch.setattr(driver, "device", lambda: offline_device)
|
||||
monkeypatch.setattr(
|
||||
service,
|
||||
"current_content",
|
||||
lambda _, **kwargs: pytest.fail(
|
||||
"Offline state must not be treated as a display confirmation"
|
||||
),
|
||||
)
|
||||
assert client.get(endpoint).json()["items"][0]["current"] is False
|
||||
|
||||
Reference in New Issue
Block a user