Skip to content

Commit

Permalink
Merge branch 'feat/support_indexed_search' into MAJOR_CHANGE/new_front
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramimashkouk committed May 8, 2024
2 parents 6ae28f8 + a89de98 commit 9ea1714
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 45 deletions.
7 changes: 5 additions & 2 deletions backend/df_designer/app/services/json_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ def write_conditions_to_file(conditions_lines, custom_conditions_file):
# TODO: make reading and writing conditions async
with open(custom_conditions_file, "w", encoding="UTF-8") as file:
for line in conditions_lines:
file.write(f"{line}\n")
if line[-1:] != "\n":
line = "".join([line, "\n"])
file.write(line)


def add_transitions(nodes, edge, condition):
Expand Down Expand Up @@ -83,7 +85,8 @@ def fill_nodes_into_script(nodes, script):

def append_condition(condition, conditions_lines):
condition = "".join([condition.data.python.action + "\n\n"])

logger.debug(f"Condition to append: {condition}")
logger.debug(f"conditions_lines before appending: {conditions_lines}")
all_lines = conditions_lines + condition.split("\n")
return all_lines

Expand Down
7 changes: 0 additions & 7 deletions backend/df_designer/app/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import pytest
from fastapi.testclient import TestClient
from httpx import AsyncClient
from httpx_ws.transport import ASGIWebSocketTransport

from app.main import app
from app.schemas.pagination import Pagination
Expand Down Expand Up @@ -78,9 +77,3 @@ def build_manager():
@pytest.fixture
def websocket_manager():
return WebSocketManager()


@pytest.fixture
async def websocket_client() -> AsyncClient:
async with AsyncClient(transport=ASGIWebSocketTransport(app), base_url="http://test") as client:
yield client
36 changes: 0 additions & 36 deletions backend/df_designer/app/tests/e2e/test.py

This file was deleted.

44 changes: 44 additions & 0 deletions backend/df_designer/app/tests/e2e/test_e2e.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import httpx
import pytest
from httpx_ws import aconnect_ws
from httpx_ws.transport import ASGIWebSocketTransport

from app.api.deps import get_build_manager, get_run_manager
from app.core.logger_config import get_logger
from app.main import app
from app.tests.conftest import override_dependency, start_process

logger = get_logger(__name__)


async def _assert_process_status(response, process_manager):
assert response.json().get("status") == "ok", "Start process response status is not 'ok'"
process_manager.check_status.assert_awaited_once()


@pytest.mark.asyncio
async def test_all(mocker):
async with httpx.AsyncClient(transport=ASGIWebSocketTransport(app)) as client:
async with override_dependency(mocker, get_build_manager) as process_manager:
response = await start_process(
client,
endpoint="http://localhost:8000/api/v1/bot/build/start",
preset_end_status="success",
)
build_id = process_manager.get_last_id()
await _assert_process_status(response, process_manager)

async with override_dependency(mocker, get_run_manager) as process_manager:
response = await start_process(
client,
endpoint=f"http://localhost:8000/api/v1/bot/run/start/{build_id}",
preset_end_status="success",
)
await _assert_process_status(response, process_manager)

run_id = process_manager.get_last_id()
async with aconnect_ws(f"http://localhost:8000/api/v1/bot/run/connect?run_id={run_id}", client) as ws:
message = await ws.receive_text()
assert message == "Start chatting"

# TODO: Check if it could send message, then recieve reply
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,5 @@ async def test_connect_to_ws(mocker, client): # noqa: F811
data = websocket.receive_text()
assert data
logger.debug("Received data: %s", data)

app.dependency_overrides = {}

0 comments on commit 9ea1714

Please sign in to comment.