File size: 1,629 Bytes
95a8a23
 
 
 
 
 
 
 
 
c175ac0
95a8a23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a59298
 
 
 
 
6724416
 
 
6a59298
6724416
 
 
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
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]


def test_version_is_single_source():
    version = (ROOT / "VERSION").read_text(encoding="utf-8").strip()
    ui = (ROOT / "ui_server.py").read_text(encoding="utf-8")
    html = (ROOT / "app.html").read_text(encoding="utf-8")
    assert version == '4.6.20'
    assert 'with_name("VERSION")' in ui
    assert "__APP_VERSION__" in html


def test_single_frontend_template():
    assert (ROOT / "app.html").exists()
    assert not (ROOT / "templates" / "app.html").exists()
    ui = (ROOT / "ui_server.py").read_text(encoding="utf-8")
    assert 'with_name("app.html")' in ui
    assert "templates/app.html" not in ui


def test_hf_space_metadata_is_valid_shape():
    readme = (ROOT / "README.md").read_text(encoding="utf-8")
    assert readme.startswith("---\n")
    meta_end = readme.find("\n---", 4)
    assert meta_end > 0
    meta = readme[4:meta_end]
    assert "sdk: docker" in meta
    assert "app_port: 7860" in meta


def test_data_health_center_wired():
    ui = (ROOT / "ui_server.py").read_text(encoding="utf-8")
    html = (ROOT / "app.html").read_text(encoding="utf-8")
    health = (ROOT / "routes" / "data_health.py").read_text(encoding="utf-8")
    appjs = (ROOT / "static" / "js" / "app.js").read_text(encoding="utf-8")
    assert '@app.get("/api/sidebar/data-health")' in health
    assert 'data-view="dataHealth"' in html
    assert 'renderDataHealth' in appjs
    health = (ROOT / "routes" / "data_health.py").read_text(encoding="utf-8")
    assert '40% metadata completeness + 35% evidence confidence + 25% repository hygiene' in health