summaryrefslogtreecommitdiff
path: root/services/api/tests/test_api.py
blob: 669143bbe55e200e22a0c44e1dc326d4b6e790c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""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"