Update test coverage timestamps and fix coroutine cleanup in task creation tests by properly closing coroutines in mocked asyncio.create_task calls
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled

This commit is contained in:
2025-12-15 08:31:12 -05:00
parent ecefbc8611
commit 27eed55c9b
6 changed files with 792 additions and 6 deletions
+12 -2
View File
@@ -549,7 +549,11 @@ class TestCreateTaskWithPlaybook:
with patch("app.routes.tasks.ws_manager") as mock_ws, \
patch("app.routes.tasks.asyncio.create_task") as mock_create_task:
mock_ws.broadcast = AsyncMock()
mock_create_task.return_value = MagicMock()
def _create_task_and_close(coro):
coro.close()
return MagicMock()
mock_create_task.side_effect = _create_task_and_close
response = await client.post(
"/api/tasks",
@@ -566,8 +570,14 @@ class TestCreateTaskWithPlaybook:
@pytest.mark.asyncio
async def test_create_task_default_target(self, client: AsyncClient, db_session):
"""Création de tâche avec target par défaut."""
with patch("app.routes.tasks.ws_manager") as mock_ws:
with patch("app.routes.tasks.ws_manager") as mock_ws, \
patch("app.routes.tasks.asyncio.create_task") as mock_create_task:
mock_ws.broadcast = AsyncMock()
def _create_task_and_close(coro):
coro.close()
return MagicMock()
mock_create_task.side_effect = _create_task_and_close
response = await client.post(
"/api/tasks",