Skip to content

Commit

Permalink
style: Black up
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramimashkouk committed Dec 4, 2024
1 parent 7c9d7db commit a119615
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
3 changes: 2 additions & 1 deletion backend/chatsky_ui/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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


Expand Down
28 changes: 18 additions & 10 deletions backend/chatsky_ui/tests/integration/test_bot.py
Original file line number Diff line number Diff line change
@@ -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()

Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}'"
10 changes: 5 additions & 5 deletions backend/chatsky_ui/tests/services/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -39,16 +39,16 @@ 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:
@pytest.mark.asyncio
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

0 comments on commit a119615

Please sign in to comment.