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) # Check Chat endpoint # We expect a 422 because we aren't sending a body, but 404 would mean it's missing. 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.") # Check that Training endpoints are GONE (404 or 405 both mean not available) 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) # Check Training endpoint (may return 200 with error message or 422 for validation) 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.") # Check Status endpoint 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.") # Check that Chat endpoint is GONE 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)