summaryrefslogtreecommitdiff
path: root/services/api/tests/test_api.py
blob: 99cf9e35f6ea8214680f21878fa536918b7c3266 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""Tests for the REST API."""
import pytest
from unittest.mock import AsyncMock, MagicMock, 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"