Logo
Explore Help
Sign In
MrSphay/odysseus
1
0
Fork 0
You've already forked odysseus
Code Issues Pull Requests Actions Packages Projects Releases Wiki Activity
Files
feature/plugin-modloader
odysseus/tests/test_tts_cache_stats.py

13 lines
416 B
Python
Raw Permalink Normal View History

TTS: include mp3 files in cache stats TTSService._put_cache writes .mp3 for MP3 audio (ID3/MPEG-framed bytes) and .wav otherwise, and the rest of the class treats both as cache entries (_get_cache iterates (".mp3", ".wav"); eviction globs "*.*"). But get_stats() enumerated the cache with `glob("*.wav")` only, so both cache_entries and cache_size_mb undercounted — reporting 0 whenever the cache held MP3 files, which is the common case for most TTS providers. Glob both extensions so the reported stats match what's actually cached. tests/test_tts_cache_stats.py writes an MP3-headed blob via _put_cache and asserts get_stats() reports one entry with non-zero size. Fails before this change.
2026-06-02 18:43:29 +07:00
from services.tts.tts_service import TTSService
def test_tts_cache_stats_counts_mp3(tmp_path):
service = TTSService(cache_dir=str(tmp_path))
# Put an MP3-headed blob (starts with b'ID3') into cache, with size > 1MB so cache_size_mb > 0
service._put_cache("k", b"ID3" + b"x" * (1024 * 1024))
stats = service.get_stats()
assert stats["cache_entries"] == 1
assert stats["cache_size_mb"] > 0
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.25.5 Page: 60ms Template: 1ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API