fix endpoint running tests manually

This commit is contained in:
Georges-Antoine Assi
2024-03-12 09:56:22 -04:00
committed by Georges-Antoine Assi
parent e024fc987f
commit af56074b72
2 changed files with 10 additions and 17 deletions

1
.gitignore vendored
View File

@@ -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

View File

@@ -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}"}
await tasks[task].run()
return {"msg": f"Task {task} run successfully!"}