summaryrefslogtreecommitdiff
path: root/services/api/tests/test_api.py
blob: f3b0a4749c6262cc0f0cebe82074c979fa057242 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"""Tests for the REST API."""

from unittest.mock import AsyncMock, patch

from fastapi.testclient import TestClient


def test_health_endpoint():
    """Health endpoint returns ok."""
    from trading_api.main import app

    # Override lifespan to skip DB
    with patch("trading_api.main.lifespan") as mock_lifespan:
        mock_lifespan.return_value.__aenter__ = AsyncMock()
        mock_lifespan.return_value.__aexit__ = AsyncMock()
        client = TestClient(app)
        response = client.get("/health")
        assert response.status_code == 200
        assert response.json()["status"] == "ok"