blitztext-app-linux/linux/tests/test_quality.py
mARTin-B78 5484bc6a1b Add Wayland, Tests, CI, and OpenWakeword integration
- Wayland support: text delivery using wtype or ydotool (paste.py)
- Testing: added Pytest coverage for routing, quality, and config logic
- CI/CD: added test-linux job to .github/workflows/ci.yml
- Feature: Hands-free dictation using an external wyoming-openwakeword
  server, respecting the /tmp/wake_muted toggle.
2026-06-05 17:16:05 +02:00

32 lines
1.2 KiB
Python

import pytest
from blitztext.quality import too_quiet, is_hallucination, clean
def test_too_quiet():
# Below duration
assert too_quiet(0.5, 1000.0, min_seconds=1.0, silence_rms=500.0) == True
# Below rms
assert too_quiet(2.0, 300.0, min_seconds=1.0, silence_rms=500.0) == True
# Good quality
assert too_quiet(2.0, 1000.0, min_seconds=1.0, silence_rms=500.0) == False
def test_is_hallucination():
# Hallucination for short duration
assert is_hallucination("Thank you.", 2.0) == True
assert is_hallucination("Vielen Dank", 1.5) == True
# Same phrase but longer duration -> Not considered a hallucination
assert is_hallucination("Thank you.", 3.0) == False
# Non-hallucination
assert is_hallucination("This is a valid sentence.", 1.0) == False
# Empty string
assert is_hallucination("", 1.0) == True
assert is_hallucination(" ", 1.0) == True
def test_clean():
assert clean(" hello world ") == "hello world"
assert clean("hello world. ", strip_trailing_punctuation=True) == "hello world"
assert clean("hello world!", strip_trailing_punctuation=True) == "hello world"
assert clean("hello world", strip_trailing_punctuation=True) == "hello world"