55# pylint:disable=too-many-arguments
66# pylint:disable=protected-access
77
8- from ast import Assert
98import asyncio
10- from datetime import timedelta
119import json
1210import logging
1311import secrets
1412from collections .abc import AsyncIterator , Awaitable , Callable
1513from dataclasses import dataclass
14+ from datetime import timedelta
15+ from pathlib import Path
1616from typing import Any
1717from unittest import mock
1818
1919import pytest
20- from tenacity import stop_after_attempt
21- from common_library .async_tools import delayed_start
22- from models_library .projects_nodes import InputsDict
23- from pytest_simcore .helpers .logging_tools import log_context
2420import simcore_service_webserver
2521import simcore_service_webserver .db_listener
2622import simcore_service_webserver .db_listener ._db_comp_tasks_listening_task
2723from aiohttp .test_utils import TestClient
24+ from common_library .async_tools import delayed_start
2825from faker import Faker
2926from models_library .projects import ProjectAtDB
27+ from models_library .projects_nodes import InputsDict
3028from pytest_mock import MockType
3129from pytest_mock .plugin import MockerFixture
30+ from pytest_simcore .helpers .logging_tools import log_context
3231from pytest_simcore .helpers .webserver_users import UserInfoDict
3332from simcore_postgres_database .models .comp_pipeline import StateType
3433from simcore_postgres_database .models .comp_tasks import NodeClass , comp_tasks
3736 create_comp_tasks_listening_task ,
3837)
3938from sqlalchemy .ext .asyncio import AsyncEngine
39+ from tenacity import stop_after_attempt
4040from tenacity .asyncio import AsyncRetrying
4141from tenacity .before_sleep import before_sleep_log
4242from tenacity .retry import retry_if_exception_type
4343from tenacity .stop import stop_after_delay
4444from tenacity .wait import wait_fixed
4545
46- from simcore_service_webserver .projects .models import ProjectDict
47-
4846logger = logging .getLogger (__name__ )
4947
5048
@@ -214,16 +212,11 @@ async def test_db_listener_triggers_on_event_with_multiple_tasks(
214212 assert any (
215213 call .args [1 ] == updated_task_id
216214 for call in spied_get_changed_comp_task_row .call_args_list
217- ), (
218- f"_get_changed_comp_task_row was not called with task_id={ updated_task_id } . Calls: { spied_get_changed_comp_task_row .call_args_list } "
219- )
215+ ), f"_get_changed_comp_task_row was not called with task_id={ updated_task_id } . Calls: { spied_get_changed_comp_task_row .call_args_list } "
220216 else :
221217 spied_get_changed_comp_task_row .assert_not_called ()
222218
223219
224- from pathlib import Path
225-
226-
227220@pytest .fixture
228221def fake_2connected_jupyterlabs_workbench (tests_data_dir : Path ) -> dict [str , Any ]:
229222 fpath = tests_data_dir / "workbench_2connected_jupyterlabs.json"
@@ -264,7 +257,6 @@ async def _check_for_stability(
264257 )
265258
266259
267- @pytest .mark .testit
268260@pytest .mark .parametrize ("user_role" , [UserRole .USER ])
269261async def test_db_listener_upgrades_projects_row_correctly (
270262 with_started_listening_task : None ,
@@ -289,19 +281,21 @@ async def test_db_listener_upgrades_projects_row_correctly(
289281 project_id = f"{ some_project .uuid } " ,
290282 node_id = node_id ,
291283 outputs = node_data .get ("outputs" , {}),
292- node_class = NodeClass .INTERACTIVE
293- if "dynamic" in node_data ["key" ]
294- else NodeClass .COMPUTATIONAL ,
284+ node_class = (
285+ NodeClass .INTERACTIVE
286+ if "dynamic" in node_data ["key" ]
287+ else NodeClass .COMPUTATIONAL
288+ ),
295289 inputs = node_data .get ("inputs" , InputsDict ()),
296290 )
297291 for node_id , node_data in fake_2connected_jupyterlabs_workbench .items ()
298292 ]
299293 assert len (tasks ) == 2 , "Expected two tasks for the two JupyterLab nodes"
300294 first_jupyter_task = tasks [0 ]
301295 second_jupyter_task = tasks [1 ]
302- assert len ( second_jupyter_task [ "inputs" ]) > 0 , (
303- "Expected inputs for the second JupyterLab task"
304- )
296+ assert (
297+ len ( second_jupyter_task [ " inputs" ]) > 0
298+ ), "Expected inputs for the second JupyterLab task"
305299 number_of_inputs_linked = len (second_jupyter_task ["inputs" ])
306300
307301 # simulate a concurrent change in all the outputs of first jupyterlab
@@ -372,9 +366,9 @@ async def _check_retrieve_rpc_called(expected_ports_retrieved: int) -> None:
372366 mock_dynamic_service_rpc .call_args_list ,
373367 )
374368 # Assert that the dynamic service RPC was called
375- assert mock_dynamic_service_rpc . call_count > 0 , (
376- "Dynamic service retrieve RPC was not called"
377- )
369+ assert (
370+ mock_dynamic_service_rpc . call_count > 0
371+ ), "Dynamic service retrieve RPC was not called"
378372 # now get we check which ports were retrieved, we expect all of them
379373 all_ports = set ()
380374 for call in mock_dynamic_service_rpc .call_args_list :
0 commit comments