|
|
| from fastapi.testclient import TestClient
|
| from app.api import app as chat_app
|
| from app.train_server import app as train_app
|
|
|
| def test_chat_server():
|
| print("Testing Chat Server (app.api)...")
|
| client = TestClient(chat_app)
|
|
|
|
|
|
|
| response = client.post("/api/chat", json={})
|
| assert response.status_code == 422, f"Expected 422 for missing body, got {response.status_code}"
|
| print(" /api/chat exists.")
|
|
|
|
|
| response = client.post("/api/train", json={})
|
| assert response.status_code in [404, 405], f"Expected 404/405 for /api/train on Chat Server, got {response.status_code}"
|
| print(" /api/train correctly missing.")
|
|
|
| def test_train_server():
|
| print("\nTesting Training Server (app.train_server)...")
|
| client = TestClient(train_app)
|
|
|
|
|
| response = client.post("/api/train", json={})
|
| assert response.status_code in [200, 422], f"Expected 200 or 422 for /api/train, got {response.status_code}"
|
| print(" /api/train exists.")
|
|
|
|
|
| response = client.get("/api/status")
|
| assert response.status_code == 200, f"Expected 200 for /api/status, got {response.status_code}"
|
| print(" /api/status exists and returns 200.")
|
|
|
|
|
| response = client.post("/api/chat", json={})
|
| assert response.status_code in [404, 405], f"Expected 404/405 for /api/chat on Training Server, got {response.status_code}"
|
| print(" /api/chat correctly missing.")
|
|
|
| if __name__ == "__main__":
|
| try:
|
| test_chat_server()
|
| test_train_server()
|
| print("\nAll server separation verification checks passed!")
|
| except Exception as e:
|
| print(f"\nVerification FAILED: {e}")
|
| exit(1)
|
|
|