test(qqbot): update voice detection tests for content_type-only logic

Update TestIsVoiceContentType to match the new behavior:
- Empty content_type with audio extensions → False (no sniffing)
- File upload with audio extension → False
- Added test_file_upload_with_audio_extension for the reported bug case
This commit is contained in:
Zioywishing 2026-05-31 13:31:34 +08:00 committed by Teknium
parent b74c033ca1
commit 3122dc1744

View file

@ -139,14 +139,21 @@ class TestIsVoiceContentType:
def test_audio_content_type(self):
assert self._fn("audio/mp3", "file.mp3") is True
def test_voice_extension(self):
assert self._fn("", "file.silk") is True
def test_voice_extension_ignored_when_content_type_empty(self):
"""content_type='' with audio extension → False (no extension sniffing)."""
assert self._fn("", "file.silk") is False
def test_non_voice(self):
assert self._fn("image/jpeg", "photo.jpg") is False
def test_audio_extension_amr(self):
assert self._fn("", "recording.amr") is True
def test_audio_extension_amr_ignored_when_content_type_empty(self):
"""content_type='' with .amr extension → False (no extension sniffing)."""
assert self._fn("", "recording.amr") is False
def test_file_upload_with_audio_extension(self):
"""File upload with audio extension must NOT be treated as voice."""
assert self._fn("file", "song.mp3") is False
assert self._fn("file", "audio-30251.instrumental..wav") is False
# ---------------------------------------------------------------------------