File size: 1,276 Bytes
f1c3ff2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Minimal tests for GET /api/about and GET /api/version."""

from __future__ import annotations

import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient


@pytest.fixture(scope="module")
def client():
    from sensorflow.about.api import router

    app = FastAPI()
    app.include_router(router)
    return TestClient(app)


def test_about_payload(client):
    body = client.get("/api/about").json()
    assert body["name"] == "Sensorflow Studio"
    assert body["version"]
    assert body["description"]
    assert body["links"]["github"].startswith("https://github.com/")
    assert "huggingface.co" in body["links"]["hf_space"]
    assert isinstance(body["releases"], list) and len(body["releases"]) >= 2
    latest = body["releases"][0]
    assert latest["version"] == body["version"]
    assert latest["date"]
    assert latest["title"]
    assert latest["highlights"]
    dates = [r["date"] for r in body["releases"]]
    assert dates == sorted(dates, reverse=True)


def test_version_payload(client):
    about = client.get("/api/about").json()
    version = client.get("/api/version").json()
    assert version["version"] == about["version"]
    assert version["name"] == about["name"]
    assert version["releases"] == about["releases"]