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,