From 07863ea09847b9191568f5b9cb652eb0606ccf4a Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Fri, 28 Apr 2023 15:44:18 -0300 Subject: [PATCH] test(websocket.py): change websocket endpoint from /ws/test_client to /chat/test_client test(websocket.py): update assertions to match new endpoint and response format --- tests/test_websocket.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/test_websocket.py b/tests/test_websocket.py index 9ec128bcf..1137c4813 100644 --- a/tests/test_websocket.py +++ b/tests/test_websocket.py @@ -5,9 +5,9 @@ from fastapi.testclient import TestClient def test_websocket_connection(client: TestClient): - with client.websocket_connect("/ws/test_client") as websocket: + with client.websocket_connect("/chat/test_client") as websocket: assert websocket.scope["client"] == ["testclient", 50000] - assert websocket.scope["path"] == "/ws/test_client" + assert websocket.scope["path"] == "/chat/test_client" def test_chat_history(client: TestClient): @@ -17,21 +17,22 @@ def test_chat_history(client: TestClient): with patch("langflow.api.chat_manager.process_graph") as mock_process_graph: mock_process_graph.return_value = ("Hello, I'm a mock response!", "") - with client.websocket_connect("/ws/test_client") as websocket: + with client.websocket_connect("/chat/test_client") as websocket: # First message should be the history history = websocket.receive_json() - assert json.loads(history) == [] # Empty history + assert history == [] # Empty history # Send a message payload = {"message": "Hello"} websocket.send_json(json.dumps(payload)) # Receive the response from the server response = websocket.receive_json() - assert json.loads(response) == { + assert response == { "is_bot": True, "message": None, - "intermediate_steps": "", "type": "start", + "intermediate_steps": "", + "files": [], } # Send another message payload = {"message": "How are you?"} @@ -39,9 +40,10 @@ def test_chat_history(client: TestClient): # Receive the response from the server response = websocket.receive_json() - assert json.loads(response) == { + assert response == { "is_bot": True, "message": "Hello, I'm a mock response!", - "intermediate_steps": "", "type": "end", + "intermediate_steps": "", + "files": [], }