File size: 2,095 Bytes
fa81843
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
Unit tests for InferRoute Quant.ai and Paper Reader plugins.
"""
import pytest
from fastapi.testclient import TestClient
from inferroute.main import app

client = TestClient(app)

def test_quant_analyze_endpoint():
    payload = {
        "ticker": "AAPL",
        "timeframe": "daily",
        "technical_indicators": {"RSI": 65.0, "MACD": "bullish"}
    }
    response = client.post(
        "/v1/plugins/quant/analyze",
        json=payload,
        headers={"Authorization": "Bearer sk-inferroute-demo"}
    )
    assert response.status_code == 200
    data = response.json()
    assert data["success"] is True
    assert data["plugin"] == "quant_analyze"
    assert data["ticker"] == "AAPL"
    assert "bullish_score" in data


def test_quant_news_sentiment_endpoint():
    payload = {
        "text": "Apple announced record quarterly revenue exceeding analyst expectations.",
        "company_context": "Apple Inc."
    }
    response = client.post(
        "/v1/plugins/quant/news-sentiment",
        json=payload,
        headers={"Authorization": "Bearer sk-inferroute-demo"}
    )
    assert response.status_code == 200
    data = response.json()
    assert data["success"] is True
    assert data["plugin"] == "quant_news_sentiment"
    assert "sentiment_score" in data


def test_paper_summarize_endpoint():
    payload = {
        "title": "ROUTERBENCH",
        "paper_text": "This paper formalizes multi-LLM routing as a multi-objective optimization problem."
    }
    response = client.post(
        "/v1/plugins/paper/summarize",
        json=payload,
        headers={"Authorization": "Bearer sk-inferroute-demo"}
    )
    assert response.status_code == 200
    data = response.json()
    assert data["success"] is True
    assert data["plugin"] == "paper_summarize"
    assert "summary" in data


def test_analytics_summary_endpoint():
    response = client.get("/v1/analytics/summary")
    assert response.status_code == 200
    data = response.json()
    assert "total_requests" in data
    assert "total_cost_saved_usd" in data
    assert "circuit_breakers" in data