File size: 980 Bytes
02518d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from fastapi.testclient import TestClient

from app.main import app

client = TestClient(app)


def test_health() -> None:
    response = client.get("/health")
    assert response.status_code == 200
    assert response.json()["status"] == "ok"


def test_fibonacci_endpoint() -> None:
    response = client.get("/api/v1/fibonacci", params={"n": 10, "algorithm": "fast_doubling"})
    assert response.status_code == 200
    data = response.json()
    assert data["value"] == "55"
    assert data["digits"] == 2


def test_range_endpoint() -> None:
    response = client.get("/api/v1/range", params={"start": 0, "end": 6, "algorithm": "matrix"})
    assert response.status_code == 200
    data = response.json()
    assert data["values"] == ["0", "1", "1", "2", "3", "5"]


def test_benchmark_endpoint() -> None:
    response = client.get("/api/v1/benchmark", params={"n": 100})
    assert response.status_code == 200
    data = response.json()
    assert len(data["results"]) == 3