diff options
| author | salmonik <raisersoft@proton.me> | 2026-04-19 15:44:33 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-04-19 15:44:33 +0200 |
| commit | b343381fea3eab26e334a1b3bba202d715f9ea2e (patch) | |
| tree | 792210018d1e11ac3b160edfe29cf878eb4e3f56 /tests/cogs/test_tts.py | |
| parent | chore: add pycord dependency, update main (diff) | |
| download | senator-sperma-b343381fea3eab26e334a1b3bba202d715f9ea2e.tar.gz senator-sperma-b343381fea3eab26e334a1b3bba202d715f9ea2e.zip | |
test: improve test assertions and edge cases
Diffstat (limited to 'tests/cogs/test_tts.py')
| -rw-r--r-- | tests/cogs/test_tts.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/cogs/test_tts.py b/tests/cogs/test_tts.py index 8c95670..de68580 100644 --- a/tests/cogs/test_tts.py +++ b/tests/cogs/test_tts.py | |||
| @@ -16,10 +16,10 @@ async def test_tts_file_output(tts_cog, mock_channel, mock_guild, bot, mock_user | |||
| 16 | ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) | 16 | ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) |
| 17 | ctx.user = mock_user | 17 | ctx.user = mock_user |
| 18 | ctx.author = mock_user | 18 | ctx.author = mock_user |
| 19 | 19 | ||
| 20 | mock_temp_path = "/tmp/test_tts.mp3" | 20 | "/tmp/test_tts.mp3" |
| 21 | 21 | ||
| 22 | with patch('cogs.tts.gTTS') as mock_gtts: | 22 | with patch('cogs.tts.gTTS') as _: |
| 23 | with patch('os.path.exists', return_value=True): | 23 | with patch('os.path.exists', return_value=True): |
| 24 | with patch('os.unlink'): | 24 | with patch('os.unlink'): |
| 25 | with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: | 25 | with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: |
| @@ -34,7 +34,7 @@ async def test_tts_voice_output_not_in_channel(tts_cog, mock_channel, mock_guild | |||
| 34 | ctx.user = mock_user | 34 | ctx.user = mock_user |
| 35 | ctx.author = mock_user | 35 | ctx.author = mock_user |
| 36 | ctx.author.voice = None | 36 | ctx.author.voice = None |
| 37 | 37 | ||
| 38 | with patch('cogs.tts.gTTS'): | 38 | with patch('cogs.tts.gTTS'): |
| 39 | with patch('os.path.exists', return_value=True): | 39 | with patch('os.path.exists', return_value=True): |
| 40 | with patch('os.unlink'): | 40 | with patch('os.unlink'): |
| @@ -48,11 +48,11 @@ async def test_tts_error_handling(tts_cog, mock_channel, mock_guild, bot, mock_u | |||
| 48 | ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) | 48 | ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) |
| 49 | ctx.user = mock_user | 49 | ctx.user = mock_user |
| 50 | ctx.author = mock_user | 50 | ctx.author = mock_user |
| 51 | 51 | ||
| 52 | with patch('cogs.tts.gTTS', side_effect=Exception("TTS Error")): | 52 | with patch('cogs.tts.gTTS', side_effect=Exception("TTS Error")): |
| 53 | with patch('os.path.exists', return_value=False): | 53 | with patch('os.path.exists', return_value=False): |
| 54 | with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: | 54 | with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: |
| 55 | await tts_cog.tts.callback(tts_cog, ctx, text="Hello", output="file") | 55 | await tts_cog.tts.callback(tts_cog, ctx, text="Hello", output="file") |
| 56 | mock_respond.assert_called_once() | 56 | mock_respond.assert_called_once() |
| 57 | args = mock_respond.call_args | 57 | args = mock_respond.call_args |
| 58 | assert "Error" in str(args) or "eror" in str(args) \ No newline at end of file | 58 | assert "Error" in str(args) or "eror" in str(args) |
