brief-rags-bench/tests/test_main.py

46 lines
1.4 KiB
Python

"""Tests for main.py endpoints."""
import pytest
from fastapi.testclient import TestClient
from unittest.mock import patch, MagicMock
from app.main import app
class TestMainEndpoints:
"""Tests for main application endpoints."""
def test_health_endpoint(self):
"""Test health check endpoint."""
client = TestClient(app)
response = client.get("/health")
assert response.status_code == 200
assert response.json() == {"status": "ok"}
@pytest.mark.asyncio
async def test_serve_frontend_app_endpoint(self):
"""Test /app endpoint serves frontend."""
from fastapi.responses import FileResponse
# Get the endpoint function
for route in app.routes:
if hasattr(route, 'path') and route.path == '/app':
result = await route.endpoint()
assert isinstance(result, FileResponse)
assert result.path == "static/index.html"
break
@pytest.mark.asyncio
async def test_root_endpoint(self):
"""Test / endpoint serves frontend."""
from fastapi.responses import FileResponse
# Get the endpoint function
for route in app.routes:
if hasattr(route, 'path') and route.path == '/':
result = await route.endpoint()
assert isinstance(result, FileResponse)
assert result.path == "static/index.html"
break