test suite

This commit is contained in:
Xoconoch
2025-06-07 14:56:13 -06:00
parent e97efb6b19
commit e81ee40a1d
15 changed files with 846 additions and 129 deletions

View File

@@ -133,7 +133,7 @@ def handle_download(playlist_id):
)
return Response(
json.dumps({"prg_file": task_id}), # prg_file is the old name for task_id
json.dumps({"task_id": task_id}),
status=202,
mimetype="application/json",
)
@@ -142,18 +142,18 @@ def handle_download(playlist_id):
@playlist_bp.route("/download/cancel", methods=["GET"])
def cancel_download():
"""
Cancel a running playlist download process by its prg file name.
Cancel a running playlist download process by its task id.
"""
prg_file = request.args.get("prg_file")
if not prg_file:
task_id = request.args.get("task_id")
if not task_id:
return Response(
json.dumps({"error": "Missing process id (prg_file) parameter"}),
json.dumps({"error": "Missing task id (task_id) parameter"}),
status=400,
mimetype="application/json",
)
# Use the queue manager's cancellation method.
result = download_queue_manager.cancel_task(prg_file)
result = download_queue_manager.cancel_task(task_id)
status_code = 200 if result.get("status") == "cancelled" else 404
return Response(json.dumps(result), status=status_code, mimetype="application/json")