import pytest from backend.app import create_app @pytest.fixture async def app(): return create_app() @pytest.fixture async def client(app): async with app.test_client() as c: yield c @pytest.mark.asyncio async def test_get_import_settings_defaults(client): resp = await client.get("/api/settings/import") assert resp.status_code == 200 body = await resp.get_json() # Defaults from the migration: assert body["min_width"] == 0 assert body["min_height"] == 0 assert body["skip_transparent"] is False assert body["transparency_threshold"] == 0.9 @pytest.mark.asyncio async def test_patch_import_settings(client): resp = await client.patch( "/api/settings/import", json={"min_width": 500, "skip_transparent": True, "transparency_threshold": 0.7}, ) assert resp.status_code == 200 body = await resp.get_json() assert body["min_width"] == 500 assert body["skip_transparent"] is True assert body["transparency_threshold"] == 0.7 @pytest.mark.asyncio async def test_patch_rejects_non_object(client): resp = await client.patch("/api/settings/import", json=[1, 2, 3]) assert resp.status_code == 400 @pytest.mark.asyncio async def test_system_stats_shape(client): resp = await client.get("/api/system/stats") assert resp.status_code == 200 body = await resp.get_json() for key in ("total_images", "total_tags", "storage_bytes", "tasks", "active_batch"): assert key in body for status in ("pending", "queued", "processing", "complete", "skipped", "failed"): assert status in body["tasks"]