Skip to content

Commit 480ae46

Browse files
committed
Websocket server test
1 parent c7dd11f commit 480ae46

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

interpreter/core/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ async def settings(payload: Dict[str, Any]):
236236

237237
return {"status": "success"}
238238

239-
@app.websocket("/ws")
239+
@app.websocket("/")
240240
async def websocket_endpoint(websocket: WebSocket):
241241
await websocket.accept()
242242
try:

tests/test_interpreter.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_server():
2828
server_thread.start()
2929

3030
# Give the server a moment to start
31-
time.sleep(8)
31+
time.sleep(2)
3232

3333
import asyncio
3434
import json
@@ -39,7 +39,7 @@ def test_server():
3939
async def test_fastapi_server():
4040
import asyncio
4141

42-
async with websockets.connect("ws://localhost:8000/ws") as websocket:
42+
async with websockets.connect("ws://localhost:8000/") as websocket:
4343
# Connect to the websocket
4444
print("Connected to WebSocket")
4545

@@ -105,7 +105,7 @@ async def test_fastapi_server():
105105
{
106106
"role": "user",
107107
"type": "message",
108-
"content": "The secret word is 'barlony'.",
108+
"content": "The secret word is 'barloney'.",
109109
},
110110
{"role": "assistant", "type": "message", "content": "Understood."},
111111
],
@@ -134,6 +134,7 @@ async def test_fastapi_server():
134134
print("WebSocket chunks sent")
135135

136136
# Wait for a specific response
137+
accumulated_content = ""
137138
while True:
138139
message = await websocket.recv()
139140
message_data = json.loads(message)
@@ -148,7 +149,7 @@ async def test_fastapi_server():
148149
print("Received expected message from server")
149150
break
150151

151-
assert "barlony" in accumulated_content
152+
assert "barloney" in accumulated_content
152153

153154
# Get the current event loop and run the test function
154155
loop = asyncio.get_event_loop()

0 commit comments

Comments
 (0)