diff --git a/backend/chatsky_ui/tests/conftest.py b/backend/chatsky_ui/tests/conftest.py index 6e8354d..18046da 100644 --- a/backend/chatsky_ui/tests/conftest.py +++ b/backend/chatsky_ui/tests/conftest.py @@ -15,7 +15,7 @@ from chatsky_ui.main import app from chatsky_ui.schemas.pagination import Pagination from chatsky_ui.schemas.preset import Preset -from chatsky_ui.services.process import RunProcess, BuildProcess +from chatsky_ui.services.process import BuildProcess, RunProcess from chatsky_ui.services.process_manager import BuildManager, RunManager @@ -50,6 +50,7 @@ async def _override_dependency(get_manager_func): if process.process.returncode is None: await process.stop() app.dependency_overrides = {} + return _override_dependency diff --git a/backend/chatsky_ui/tests/integration/test_bot.py b/backend/chatsky_ui/tests/integration/test_bot.py index e6d276d..4908c8f 100644 --- a/backend/chatsky_ui/tests/integration/test_bot.py +++ b/backend/chatsky_ui/tests/integration/test_bot.py @@ -1,15 +1,15 @@ import asyncio +import os + import pytest +from dotenv import load_dotenv from httpx import AsyncClient from httpx._transports.asgi import ASGITransport -from dotenv import load_dotenv -import os -from chatsky_ui.main import app -from chatsky_ui.schemas.process_status import Status from chatsky_ui.api.deps import get_build_manager, get_run_manager from chatsky_ui.core.logger_config import get_logger - +from chatsky_ui.main import app +from chatsky_ui.schemas.process_status import Status load_dotenv() @@ -18,9 +18,11 @@ logger = get_logger(__name__) + @pytest.mark.asyncio @pytest.mark.parametrize( - "preset_status, expected_status", [("failure", Status.FAILED), ("loop", Status.RUNNING), ("success", Status.COMPLETED)] + "preset_status, expected_status", + [("failure", Status.FAILED), ("loop", Status.RUNNING), ("success", Status.COMPLETED)], ) async def test_start_build(mocker, override_dependency, preset_status, expected_status): async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as async_client: @@ -48,11 +50,14 @@ async def test_start_build(mocker, override_dependency, preset_status, expected_ return else: raise Exception( - f"Process with expected end status '{preset_status}' timed out with return code '{process.process.returncode}'." + f"Process with expected end status '{preset_status}' timed out with " + f"return code '{process.process.returncode}'." ) from exc current_status = await process_manager.get_status(process_id) - assert current_status == expected_status, f"Current process status '{current_status}' did not match the expected '{expected_status}'" + assert ( + current_status == expected_status + ), f"Current process status '{current_status}' did not match the expected '{expected_status}'" @pytest.mark.asyncio @@ -82,8 +87,11 @@ async def test_start_run(override_dependency, preset_status, expected_status, du return else: raise Exception( - f"Process with expected end status '{preset_status}' timed out with return code '{process.process.returncode}'." + f"Process with expected end status '{preset_status}' timed out with " + f"return code '{process.process.returncode}'." ) from exc current_status = await process_manager.get_status(process_id) - assert current_status == expected_status, f"Current process status '{current_status}' did not match the expected '{expected_status}'" + assert ( + current_status == expected_status + ), f"Current process status '{current_status}' did not match the expected '{expected_status}'" diff --git a/backend/chatsky_ui/tests/services/test_process.py b/backend/chatsky_ui/tests/services/test_process.py index 7abe4e0..2fb1af4 100644 --- a/backend/chatsky_ui/tests/services/test_process.py +++ b/backend/chatsky_ui/tests/services/test_process.py @@ -2,9 +2,9 @@ import pytest -from chatsky_ui.schemas.process_status import Status from chatsky_ui.core.config import settings from chatsky_ui.db.base import read_conf +from chatsky_ui.schemas.process_status import Status class TestRunProcess: @@ -39,9 +39,9 @@ async def test_stop(self, run_process): async def test_update_db_info(self, run_process, dummy_run_id): process = await run_process("echo Hello") await process.update_db_info() - + runs_conf = await read_conf(settings.runs_path) - assert dummy_run_id in [conf["id"] for conf in runs_conf] # type: ignore + assert dummy_run_id in [conf["id"] for conf in runs_conf] # type: ignore class TestBuildProcess: @@ -49,6 +49,6 @@ class TestBuildProcess: async def test_update_db_info(self, build_process, dummy_build_id): process = await build_process("echo Hello") await process.update_db_info() - + builds_conf = await read_conf(settings.builds_path) - assert dummy_build_id in [conf["id"] for conf in builds_conf] # type: ignore + assert dummy_build_id in [conf["id"] for conf in builds_conf] # type: ignore