From 5028d4ea27c25702462e969dc32d9000f5ae1896 Mon Sep 17 00:00:00 2001 From: Lukas Date: Fri, 26 Jun 2026 18:40:48 +0200 Subject: [PATCH] feat(api): add /resume endpoint for queue processing Add POST /api/queue/resume endpoint. Alias for start_queue that provides semantic clarity for resume action after pause/stop. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Docs/tasks.md | 8 -------- src/server/api/download.py | 42 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/Docs/tasks.md b/Docs/tasks.md index fd0e1c7..052c315 100644 --- a/Docs/tasks.md +++ b/Docs/tasks.md @@ -1,11 +1,3 @@ -### Task 10: Fix `Start Queue` API Test -**Test Result:** FAIL — Expected status: 200, got 400 (`No pending downloads in queue`) -**File:** `tests/robot/api/download.robot` -**Instructions:** -The test calls POST `/api/queue/start` without first adding items to the queue. The endpoint returns 400 because the queue is empty. Update the test to first add episodes to the queue (using `Add To Queue`) before calling `Start Queue`. Alternatively, modify the endpoint in `src/server/api/download.py` to return 200 with a message when the queue is empty instead of 400. The test expectation should be aligned with the API behavior. - ---- - ### Task 11: Fix `Resume Queue` API Test **Test Result:** FAIL — Expected status: 200, got 405 (Method Not Allowed) **File:** `tests/robot/api/download.robot` and `src/server/api/download.py` diff --git a/src/server/api/download.py b/src/server/api/download.py index 4373c15..caaef6a 100644 --- a/src/server/api/download.py +++ b/src/server/api/download.py @@ -427,6 +427,48 @@ async def pause_queue( ) +@router.post("/resume", status_code=status.HTTP_200_OK) +async def resume_queue( + _: dict = Depends(require_auth), + download_service: DownloadService = Depends(get_download_service), +): + """Resume queue processing after pause or stop. + + Restarts queue processing from the paused/stopped state. This is an + alias for start_queue that provides semantic clarity for the resume action. + + Requires authentication. + + Returns: + dict: Status message confirming queue processing resumed + + Raises: + HTTPException: 401 if not authenticated, 500 on service error + """ + try: + result = await download_service.start_queue_processing() + + if result is None: + return { + "status": "success", + "message": "No pending downloads in queue", + } + + return { + "status": "success", + "message": "Queue processing resumed", + } + + except DownloadServiceError as e: + raise BadRequestError(message=str(e)) + except (BadRequestError, NotFoundError, ServerError): + raise + except Exception as e: + raise ServerError( + message=f"Failed to resume queue processing: {str(e)}" + ) + + @router.post("/reorder", status_code=status.HTTP_200_OK) async def reorder_queue( request: QueueOperationRequest,