Spaces:
Sleeping
Sleeping
| import pytest | |
| from httpx import AsyncClient | |
| from unittest.mock import patch, MagicMock | |
| class TestHealthEndpoint: | |
| async def test_health_check(self, client: AsyncClient): | |
| with patch('app.db.redis_client.redis_client.ping', return_value=True), \ | |
| patch('app.db.mongodb.mongodb.client.admin.command', return_value={'ok': 1}), \ | |
| patch('app.db.vector_store.vector_store.client.get_collections', return_value=MagicMock()): | |
| response = await client.get("/health/") | |
| assert response.status_code in [200, 503] | |
| data = response.json() | |
| assert "status" in data | |
| class TestChatEndpoints: | |
| async def test_chat_without_rag(self, client: AsyncClient, clear_cache): | |
| payload = { | |
| "message": "Hello, how are you?", | |
| "use_rag": False | |
| } | |
| response = await client.post("/chat/stream", json=payload) | |
| assert response.status_code == 200 | |
| async def test_chat_with_rag(self, client: AsyncClient, clear_cache): | |
| payload = { | |
| "message": "What is attention mechanism?", | |
| "use_rag": True, | |
| "session_id": "test-session" | |
| } | |
| response = await client.post("/chat/stream", json=payload) | |
| assert response.status_code == 200 | |