Reconstruction propre de l'ancien projet Dictée. Bundle id neuf (cloud.mrtechlab.zonza), chemin de build unique vers /Applications (plus jamais de builds /tmp enregistrés dans LaunchServices). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
62 lines
1.7 KiB
Python
62 lines
1.7 KiB
Python
from core import CONFIG, validate_config, is_long_enough, clean_transcript
|
|
|
|
|
|
def test_config_has_required_keys():
|
|
for key in ("model", "language", "hotkey", "sounds", "min_duration_s", "sample_rate"):
|
|
assert key in CONFIG
|
|
|
|
|
|
def test_config_defaults():
|
|
assert CONFIG["language"] == "fr"
|
|
assert CONFIG["min_duration_s"] == 0.3
|
|
assert CONFIG["sample_rate"] == 16000
|
|
|
|
|
|
def test_validate_config_accepts_default():
|
|
validate_config(CONFIG) # ne doit pas lever
|
|
|
|
|
|
def test_validate_config_rejects_bad_duration():
|
|
import pytest
|
|
bad = dict(CONFIG, min_duration_s=-1)
|
|
with pytest.raises(ValueError):
|
|
validate_config(bad)
|
|
|
|
|
|
def test_is_long_enough_true():
|
|
# 1 seconde d'audio à 16000 Hz = 16000 échantillons
|
|
assert is_long_enough(16000, sample_rate=16000, min_duration_s=0.3) is True
|
|
|
|
|
|
def test_is_long_enough_false_too_short():
|
|
# 0.1 s = 1600 échantillons < seuil 0.3 s
|
|
assert is_long_enough(1600, sample_rate=16000, min_duration_s=0.3) is False
|
|
|
|
|
|
def test_is_long_enough_empty():
|
|
assert is_long_enough(0, sample_rate=16000, min_duration_s=0.3) is False
|
|
|
|
|
|
def test_clean_transcript_trims():
|
|
assert clean_transcript(" bonjour ") == "bonjour"
|
|
|
|
|
|
def test_clean_transcript_collapses_internal_whitespace():
|
|
assert clean_transcript("crée moi un\noutil") == "crée moi un outil"
|
|
|
|
|
|
def test_clean_transcript_empty_stays_empty():
|
|
assert clean_transcript(" ") == ""
|
|
|
|
|
|
def test_config_has_ui_keys():
|
|
for key in ("fps", "circle_base_radius", "circle_amplitude", "circle_color_rgb"):
|
|
assert key in CONFIG
|
|
|
|
|
|
def test_config_ui_defaults():
|
|
assert CONFIG["fps"] == 30
|
|
assert CONFIG["circle_base_radius"] > 0
|
|
assert CONFIG["circle_amplitude"] > 0
|
|
assert len(CONFIG["circle_color_rgb"]) == 3
|