/ backend / tests / test_main.py
test_main.py
 1  """Tests for the main FastAPI application."""
 2  
 3  import pytest
 4  from fastapi.testclient import TestClient
 5  
 6  
 7  @pytest.fixture
 8  def client():
 9      """Create a test client for the FastAPI app."""
10      from main import app
11      return TestClient(app)
12  
13  
14  def test_root_endpoint(client):
15      """Test the root endpoint returns expected data."""
16      response = client.get("/")
17      assert response.status_code == 200
18      data = response.json()
19      assert "name" in data
20      assert "version" in data
21      assert "status" in data
22      assert data["status"] == "running"
23  
24  
25  def test_health_endpoint(client):
26      """Test the health check endpoint."""
27      response = client.get("/health")
28      assert response.status_code == 200
29      data = response.json()
30      assert data["status"] == "healthy"