remove unused test

This commit is contained in:
Georges-Antoine Assi
2026-03-12 23:14:17 -04:00
parent 4db997d69f
commit ffbd997940

View File

@@ -208,141 +208,6 @@ class TestListTasks:
assert response.status_code == status.HTTP_403_FORBIDDEN
class TestRunAllTasks:
"""Test suite for the run_all_tasks endpoint"""
@patch("endpoints.tasks.low_prio_queue.enqueue", return_value=create_mock_job())
@patch(
"endpoints.tasks.manual_tasks",
[
{
"name": "task1",
"type": TaskType.CLEANUP,
"task": Mock(
spec=Task,
task_type=TaskType.CLEANUP,
title="Test Task",
description="Test Description",
enabled=True,
manual_run=True,
run=Mock(),
),
},
{
"name": "task2",
"type": TaskType.CLEANUP,
"task": Mock(
spec=Task,
task_type=TaskType.CLEANUP,
title="Test Task",
description="Test Description",
enabled=True,
manual_run=True,
run=Mock(),
),
},
],
)
@patch(
"endpoints.tasks.scheduled_tasks",
[
{
"name": "task3",
"type": TaskType.UPDATE,
"task": Mock(
spec=Task,
task_type=TaskType.UPDATE,
title="Update Task",
description="Update Description",
enabled=True,
manual_run=True,
run=Mock(),
),
},
{
"name": "task4",
"type": TaskType.UPDATE,
"task": Mock(
spec=Task,
task_type=TaskType.UPDATE,
title="Disabled Update Task",
description="Disabled Update Description",
enabled=False,
manual_run=True,
run=Mock(),
), # Disabled
},
],
)
def test_run_all_tasks_success(self, mock_queue, client, access_token):
"""Test successful running of all runnable tasks"""
response = client.post(
"/api/tasks/run", headers={"Authorization": f"Bearer {access_token}"}
)
assert response.status_code == status.HTTP_200_OK
data = response.json()
assert len(data) == 3
assert data[0]["task_name"] == "task1"
assert data[1]["task_name"] == "task2"
assert data[2]["task_name"] == "task3"
@patch("endpoints.tasks.low_prio_queue")
@patch("endpoints.tasks.manual_tasks", [])
@patch("endpoints.tasks.scheduled_tasks", [])
def test_run_all_tasks_no_runnable_tasks(self, mock_queue, client, access_token):
"""Test running all tasks when no tasks are runnable"""
response = client.post(
"/api/tasks/run", headers={"Authorization": f"Bearer {access_token}"}
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
data = response.json()
assert data["detail"] == "No runnable tasks available to run"
# Verify that enqueue was not called
mock_queue.assert_not_called()
@patch("endpoints.tasks.low_prio_queue")
@patch(
"endpoints.tasks.manual_tasks",
[
{
"name": "task1",
"type": TaskType.CLEANUP,
"task": Mock(
spec=Task, enabled=True, manual_run=False, run=Mock()
), # Not manual
},
{
"name": "task2",
"type": TaskType.CLEANUP,
"task": Mock(
spec=Task, enabled=False, manual_run=True, run=Mock()
), # Disabled
},
],
)
@patch("endpoints.tasks.scheduled_tasks", [])
def test_run_all_tasks_mixed_conditions(self, mock_queue, client, access_token):
"""Test running all tasks with mixed enabled/disabled and manual/non-manual tasks"""
response = client.post(
"/api/tasks/run", headers={"Authorization": f"Bearer {access_token}"}
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
data = response.json()
assert data["detail"] == "No runnable tasks available to run"
# Verify that enqueue was not called since no tasks are both enabled and manual
mock_queue.enqueue.assert_not_called()
def test_run_all_tasks_unauthorized(self, client):
"""Test that unauthorized requests are rejected"""
response = client.post("/api/tasks/run")
assert response.status_code == status.HTTP_403_FORBIDDEN
class TestRunSingleTask:
"""Test suite for the run_single_task endpoint"""