File size: 1,160 Bytes
0125724
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
TradeSense AI — FastAPI REST API Endpoint Tests
"""

import pytest
from fastapi.testclient import TestClient
from backend.app.main import app

client = TestClient(app)


def test_api_health():
    """Verify GET /api/v1/health returns status HEALTHY."""
    response = client.get("/api/v1/health")
    assert response.status_code == 200
    data = response.json()
    assert data["status"] == "HEALTHY"
    assert data["version"] == "1.3.0"
    assert data["stage_1_universe_count"] == 10


def test_api_calendar_sessions():
    """Verify session calculator accurately resolves NSE trading days."""
    response = client.get("/api/v1/calendar/sessions?target_date=2026-09-04")
    assert response.status_code == 200
    data = response.json()
    assert data["reference_date"] == "2026-09-04"
    assert data["next_trading_session"] == "2026-09-07" # Skips weekend to Monday trading session


def test_api_journal_initial():
    """Verify GET /api/v1/journal returns structure."""
    response = client.get("/api/v1/journal")
    assert response.status_code == 200
    data = response.json()
    assert "track_record" in data
    assert "entries" in data