File size: 1,011 Bytes
287541f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import json
from config import ROOT, LANGUAGES, MAX_CHARS


def test_examples_cover_all_languages_and_use_real_presets(monkeypatch):
    monkeypatch.setenv("ZONOS_UI_ONLY", "1")
    import app
    catalog={v["name"] for v in app.CATALOG}
    assert len(app.EXAMPLES)==9
    assert {v["language"] for v in app.EXAMPLES.values()}==set(LANGUAGES)-{"en_gb"}
    for code in app.EXAMPLES:
        text,picker,source=app.load_example(code)
        voice=json.loads(picker)
        assert 0<len(text)<=MAX_CHARS and voice["voice"] in catalog and source=="Preset"
        assert voice["language"]==app.EXAMPLES[code]["language"] and voice["custom"] is False
    assert set(app.demo.get_api_info()["named_endpoints"])=={"/generate","/cancel"}
    assert app.settings_markup().count('class="example-button"')==9
    example_events=[e for e in app.demo.config["dependencies"] if any(t[1].startswith("example_") for t in e["targets"])]
    assert len(example_events)==9 and all(e["queue"] is False for e in example_events)