From 3122dc17445a3bdc847936a875340f8192fa55b0 Mon Sep 17 00:00:00 2001 From: Zioywishing Date: Sun, 31 May 2026 13:31:34 +0800 Subject: [PATCH] test(qqbot): update voice detection tests for content_type-only logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tests/gateway/test_qqbot.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/gateway/test_qqbot.py b/tests/gateway/test_qqbot.py index 562db57193d8..b0e9e9c53335 100644 --- a/tests/gateway/test_qqbot.py +++ b/tests/gateway/test_qqbot.py @@ -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 # ---------------------------------------------------------------------------