fc3d: settings API exposes scheduling knobs with bounds validation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -82,6 +82,68 @@ async def test_system_stats_shape(client):
|
||||
assert status in body["tasks"]
|
||||
|
||||
|
||||
# --- FC-3d: scheduling knobs ----------------------------------------------
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_includes_scheduling_defaults(client):
|
||||
resp = await client.get("/api/settings/import")
|
||||
body = await resp.get_json()
|
||||
assert body["download_schedule_default_seconds"] == 28800
|
||||
assert body["download_event_retention_days"] == 90
|
||||
assert body["download_failure_warning_threshold"] == 5
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_patch_scheduling_defaults(client):
|
||||
resp = await client.patch("/api/settings/import", json={
|
||||
"download_schedule_default_seconds": 7200,
|
||||
"download_event_retention_days": 30,
|
||||
"download_failure_warning_threshold": 3,
|
||||
})
|
||||
assert resp.status_code == 200
|
||||
body = await resp.get_json()
|
||||
assert body["download_schedule_default_seconds"] == 7200
|
||||
assert body["download_event_retention_days"] == 30
|
||||
assert body["download_failure_warning_threshold"] == 3
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_patch_rejects_below_min_interval(client):
|
||||
resp = await client.patch(
|
||||
"/api/settings/import",
|
||||
json={"download_schedule_default_seconds": 30},
|
||||
)
|
||||
assert resp.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_patch_rejects_above_max_interval(client):
|
||||
resp = await client.patch(
|
||||
"/api/settings/import",
|
||||
json={"download_schedule_default_seconds": 90000},
|
||||
)
|
||||
assert resp.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_patch_rejects_zero_retention_days(client):
|
||||
resp = await client.patch(
|
||||
"/api/settings/import",
|
||||
json={"download_event_retention_days": 0},
|
||||
)
|
||||
assert resp.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_patch_rejects_zero_failure_threshold(client):
|
||||
resp = await client.patch(
|
||||
"/api/settings/import",
|
||||
json={"download_failure_warning_threshold": 0},
|
||||
)
|
||||
assert resp.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_system_stats_integrity_counts(client, db):
|
||||
from backend.app.models import ImageRecord
|
||||
|
||||
Reference in New Issue
Block a user