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>
This commit is contained in:
@@ -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
|
### Task 11: Fix `Resume Queue` API Test
|
||||||
**Test Result:** FAIL — Expected status: 200, got 405 (Method Not Allowed)
|
**Test Result:** FAIL — Expected status: 200, got 405 (Method Not Allowed)
|
||||||
**File:** `tests/robot/api/download.robot` and `src/server/api/download.py`
|
**File:** `tests/robot/api/download.robot` and `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)
|
@router.post("/reorder", status_code=status.HTTP_200_OK)
|
||||||
async def reorder_queue(
|
async def reorder_queue(
|
||||||
request: QueueOperationRequest,
|
request: QueueOperationRequest,
|
||||||
|
|||||||
Reference in New Issue
Block a user