mirror of
https://github.com/rommapp/romm.git
synced 2026-02-18 23:42:07 +01:00
fix endpoint running tests manually
This commit is contained in:
committed by
Georges-Antoine Assi
parent
e024fc987f
commit
af56074b72
1
.gitignore
vendored
1
.gitignore
vendored
@@ -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
|
||||
|
||||
@@ -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!"}
|
||||
|
||||
Reference in New Issue
Block a user