mirror of
https://github.com/aimingmed/aimingmed-ai.git
synced 2026-01-31 19:54:46 +08:00
test
This commit is contained in:
parent
9c89b63d67
commit
a1cb3732ba
@ -36,7 +36,7 @@ jobs:
|
||||
image_config:
|
||||
- IMAGE_NAME: backend-aimingmedai
|
||||
BUILD_CONTEXT: ./app/backend
|
||||
DOCKERFILE: ./app/backend/Dockerfile
|
||||
DOCKERFILE: ./app/backend/Dockerfile.prod
|
||||
- IMAGE_NAME: frontend-aimingmedai
|
||||
BUILD_CONTEXT: ./app/frontend
|
||||
DOCKERFILE: ./app/frontend/Dockerfile.test
|
||||
@ -11,7 +11,7 @@ services:
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile
|
||||
container_name: backend
|
||||
container_name: backend-aimingmedai
|
||||
platform: linux/amd64
|
||||
# command: pipenv run uvicorn main:app --reload --workers 1 --host 0.0.0.0 --port 8765
|
||||
volumes:
|
||||
@ -26,7 +26,7 @@ services:
|
||||
build:
|
||||
context: ./frontend
|
||||
dockerfile: Dockerfile.test
|
||||
container_name: frontend
|
||||
container_name: frontend-aimingmedai
|
||||
volumes:
|
||||
- ./frontend:/usr/src/app
|
||||
- /usr/src/app/node_modules
|
||||
@ -40,6 +40,10 @@ services:
|
||||
tests:
|
||||
build:
|
||||
context: ./tests
|
||||
container_name: tests-aimingmedai
|
||||
# depends_on:
|
||||
# - backend
|
||||
# - frontend
|
||||
environment:
|
||||
FRONTEND_URL: http://frontend:80
|
||||
BACKEND_URL: http://backend:80
|
||||
|
||||
@ -11,6 +11,9 @@ evonik-dummy = "*"
|
||||
pyrsistent = "*"
|
||||
pyjwt = "*"
|
||||
pydantic = "*"
|
||||
websockets = "*"
|
||||
pytest-asyncio = "*"
|
||||
pytest-cov = "*"
|
||||
|
||||
[dev-packages]
|
||||
autopep8 = "*"
|
||||
|
||||
29
app/tests/tests/integration/backend/test_frontend_backend.py
Normal file
29
app/tests/tests/integration/backend/test_frontend_backend.py
Normal file
@ -0,0 +1,29 @@
|
||||
import pytest
|
||||
import subprocess
|
||||
import requests
|
||||
import json
|
||||
import time
|
||||
import os
|
||||
import asyncio
|
||||
import websockets
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_chatbot_integration():
|
||||
# Send a request to the chatbot endpoint
|
||||
url = "ws://backend-aimingmedai:80/ws"
|
||||
data = [{"content": "Hello"}]
|
||||
try:
|
||||
async with websockets.connect(url) as websocket:
|
||||
await websocket.send(json.dumps(data))
|
||||
response = await websocket.recv()
|
||||
assert response is not None
|
||||
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