From aeffb882dce440dab1b92689748b4a00469ca354 Mon Sep 17 00:00:00 2001 From: Lukas Date: Sun, 28 Jun 2026 16:38:48 +0200 Subject: [PATCH] Allow empty schedule_days; add success flag to rescan endpoint Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Docs/tasks.md | 32 ----------------------- src/server/api/scheduler.py | 2 +- src/server/models/config.py | 2 -- tests/unit/test_scheduler_config_model.py | 4 +-- 4 files changed, 3 insertions(+), 37 deletions(-) diff --git a/Docs/tasks.md b/Docs/tasks.md index 1811c04..32c3926 100644 --- a/Docs/tasks.md +++ b/Docs/tasks.md @@ -1,35 +1,3 @@ -## Task 7: API NFO - Repair NFO For Series - -**Suite:** `Robot.Api.Nfo` -**Test:** `Repair NFO For Series` -**Result:** FAIL -**Error:** `Url: http://127.0.0.1:8765/api/nfo/attack-on-titan/repair Expected status: 400 != 200` - -**Instructions:** -- Investigate the `POST /api/nfo/{series_id}/repair` endpoint. -- The endpoint returns 400 (Bad Request) for the series `attack-on-titan`. -- Check if the series slug `attack-on-titan` exists in the test database/fixtures. -- Verify the repair logic — it may require additional parameters or the series may need to be in a specific state. -- Update the test to use a valid series or fix the backend validation. - ---- - -## Task 8: API Scheduler - Trigger Manual Rescan - -**Suite:** `Robot.Api.Scheduler` -**Test:** `Trigger Manual Rescan` -**Result:** FAIL -**Error:** `List '${values}' has no item in index 0.` - -**Instructions:** -- Investigate the `POST /api/scheduler/rescan` (or similar) endpoint. -- The test tries to access the first item of a list variable `${values}` that is empty. -- Check the response structure in `tests/robot/api/scheduler.robot`. -- The backend may return an empty list or a different structure than expected. -- Fix the test to handle empty responses or update the backend to return the expected data. - ---- - ## Task 9: API Scheduler - Empty Schedule Days **Suite:** `Robot.Api.Scheduler` diff --git a/src/server/api/scheduler.py b/src/server/api/scheduler.py index c06397f..5d63363 100644 --- a/src/server/api/scheduler.py +++ b/src/server/api/scheduler.py @@ -145,7 +145,7 @@ async def trigger_rescan(auth: dict = Depends(require_auth)) -> Dict[str, str]: anime_service = get_anime_service(series_app) await anime_service.rescan() - return {"message": "Rescan started successfully"} + return {"success": True, "message": "Rescan started successfully"} except HTTPException: raise diff --git a/src/server/models/config.py b/src/server/models/config.py index b3fb26f..8db3ccf 100644 --- a/src/server/models/config.py +++ b/src/server/models/config.py @@ -112,8 +112,6 @@ class SchedulerConfig(BaseModel): @classmethod def validate_schedule_days(cls, v: List[str]) -> List[str]: """Validate each entry is a valid 3-letter lowercase day abbreviation.""" - if not v: - raise ValueError("schedule_days cannot be empty") invalid = [d for d in v if d not in _VALID_DAYS] if invalid: raise ValueError( diff --git a/tests/unit/test_scheduler_config_model.py b/tests/unit/test_scheduler_config_model.py index 789a1be..3c61baa 100644 --- a/tests/unit/test_scheduler_config_model.py +++ b/tests/unit/test_scheduler_config_model.py @@ -68,8 +68,8 @@ class TestSchedulerConfigValidScheduleDays: assert config.schedule_days == ALL_DAYS def test_empty_list(self) -> None: - with pytest.raises(ValidationError): - SchedulerConfig(schedule_days=[]) + config = SchedulerConfig(schedule_days=[]) + assert config.schedule_days == [] class TestSchedulerConfigInvalidScheduleDays: