mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-15 19:32:21 +02:00
Server-side photo editor: natural-language editor agent route
(/api/editor/agent), photo_editor tool family + style guide, image-op
provider proxy with progress, email server hardening, gallery/hwfit
routes, and graceful shutdown.
Source: vendor/photocraft (ad1cff44) editor-server files, merged onto
upstream/dev (a8c147b2). Conflict resolution documented in
pr_work/B_conflicts.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
"""Tests for src/activity.py — in-flight heavy-image-op counters (safe restart)."""
|
|
from src import activity
|
|
|
|
|
|
def test_image_op_counter_increments_and_decrements():
|
|
assert activity.heavy_image_ops_active() == 0
|
|
activity.begin_image_op("a")
|
|
activity.begin_image_op("a")
|
|
assert activity.heavy_image_ops_active() == 2
|
|
activity.end_image_op("a")
|
|
assert activity.heavy_image_ops_active() == 1
|
|
activity.end_image_op("a")
|
|
assert activity.heavy_image_ops_active() == 0
|
|
# never goes negative
|
|
activity.end_image_op("a")
|
|
assert activity.heavy_image_ops_active() == 0
|
|
|
|
|
|
def test_image_op_context_manager_and_busy():
|
|
assert activity.busy() is False
|
|
with activity.image_op("/api/image/inpaint"):
|
|
assert activity.busy() is True
|
|
snap = activity.activity()
|
|
assert snap["image_ops"] == 1
|
|
assert snap["image_ops_by_name"].get("/api/image/inpaint") == 1
|
|
assert activity.busy() is False
|
|
assert activity.activity()["image_ops"] == 0
|
|
|
|
|
|
def test_image_op_released_on_exception():
|
|
try:
|
|
with activity.image_op("boom"):
|
|
raise RuntimeError("x")
|
|
except RuntimeError:
|
|
pass
|
|
assert activity.heavy_image_ops_active() == 0
|