mirror of
https://github.com/aimingmed/aimingmed-ai.git
synced 2026-02-06 15:26:55 +08:00
replace test that ping only
This commit is contained in:
parent
749da60a0e
commit
aaa03db4c7
@ -1,24 +1,11 @@
|
|||||||
import pytest
|
import pytest
|
||||||
import json
|
|
||||||
import websockets
|
import websockets
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_chatbot_integration():
|
async def test_websocket_connection():
|
||||||
# Send a request to the chatbot endpoint
|
|
||||||
url = "ws://backend-aimingmedai:80/ws"
|
url = "ws://backend-aimingmedai:80/ws"
|
||||||
data = [{"content": "Hello"}]
|
|
||||||
try:
|
try:
|
||||||
async with websockets.connect(url) as websocket:
|
async with websockets.connect(url):
|
||||||
await websocket.send(json.dumps(data))
|
assert True # If the connection is established, the test passes
|
||||||
response = await websocket.recv()
|
except Exception:
|
||||||
assert response is not None
|
assert False # If any exception occurs, the test fails
|
||||||
try:
|
|
||||||
response_json = json.loads(response)
|
|
||||||
assert "type" in response_json
|
|
||||||
assert "payload" in response_json
|
|
||||||
assert response_json["payload"] == ""
|
|
||||||
except json.JSONDecodeError:
|
|
||||||
assert False, "Invalid JSON response"
|
|
||||||
except Exception as e:
|
|
||||||
pytest.fail(f"Request failed: {e}")
|
|
||||||
Loading…
x
Reference in New Issue
Block a user