From af56074b72ada8a797012e35f886bcabb8f4e54f Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Tue, 12 Mar 2024 09:56:22 -0400 Subject: [PATCH] fix endpoint running tests manually --- .gitignore | 1 + backend/endpoints/tasks.py | 26 +++++++++----------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 93aad4671..2edc11460 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,7 @@ backend/romm_test/resources backend/romm_test/logs backend/romm_test/config .pytest_cache +/romm_test # service worker frontend/dev-dist diff --git a/backend/endpoints/tasks.py b/backend/endpoints/tasks.py index e8921726f..3ea7a731e 100644 --- a/backend/endpoints/tasks.py +++ b/backend/endpoints/tasks.py @@ -7,32 +7,27 @@ from tasks.update_switch_titledb import update_switch_titledb_task router = APIRouter() -@protected_route(router.post, "/tasks", ["tasks.run"]) -async def run_tasks(request: Request, action: str) -> MessageResponse: +@protected_route(router.post, "/tasks/run", ["tasks.run"]) +async def run_tasks(request: Request) -> MessageResponse: """Run all tasks endpoint Args: request (Request): Fastapi Request object - action: Action to perform on tasks Returns: RunTasksResponse: Standard message response """ - if action == "run": - await update_mame_xml_task.run() - await update_switch_titledb_task.run() - return {"msg": f"All tasks {action} successfully!"} - - return {"msg": "No action performed on tasks"} + await update_mame_xml_task.run() + await update_switch_titledb_task.run() + return {"msg": "All tasks ran successfully!"} -@protected_route(router.post, "/tasks/{task}", ["tasks.run"]) -async def run_task(request: Request, task: str, action: str) -> MessageResponse: +@protected_route(router.post, "/tasks/{task}/run", ["tasks.run"]) +async def run_task(request: Request, task: str) -> MessageResponse: """Run all tasks endpoint Args: request (Request): Fastapi Request object - action: Action to perform on tasks Returns: RunTasksResponse: Standard message response """ @@ -42,8 +37,5 @@ async def run_task(request: Request, task: str, action: str) -> MessageResponse: "switch_titledb": update_switch_titledb_task } - if action == "run": - await tasks[task].run() - return {"msg": f"Task {task} {action} successfully!"} - - return {"msg": "No action performed on task {task}"} \ No newline at end of file + await tasks[task].run() + return {"msg": f"Task {task} run successfully!"}