aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cogs/test_music_join.py
diff options
context:
space:
mode:
authorsalmonik <raisersoft@proton.me>2026-05-20 15:40:18 +0200
committersalmonik <raisersoft@proton.me>2026-05-20 15:40:18 +0200
commit4663f260b55de0975661fda1c00f60d2ca6e4506 (patch)
treeb649850859595542f8e7916a5513e0840e911318 /tests/cogs/test_music_join.py
parentFix TTS and AI voice playback bugs (diff)
downloadsenator-sperma-4663f260b55de0975661fda1c00f60d2ca6e4506.tar.gz
senator-sperma-4663f260b55de0975661fda1c00f60d2ca6e4506.zip
Clean up consumers: replace polling with VoiceManager.play_source()
- cron.py: replace while-is_playing polling with VoiceManager.play_source() - vclogs.py: replace while-is_playing polling with VoiceManager.play_source() - stop.py: use VoiceManager.disconnect() instead of raw voice_client - join.py: use VoiceManager.connect() instead of raw channel.connect() - voice.py: add back join_by_channel_id() convenience method - Tests: update for new VoiceManager method names and signatures
Diffstat (limited to 'tests/cogs/test_music_join.py')
-rw-r--r--tests/cogs/test_music_join.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/tests/cogs/test_music_join.py b/tests/cogs/test_music_join.py
index 0176759..b40d93a 100644
--- a/tests/cogs/test_music_join.py
+++ b/tests/cogs/test_music_join.py
@@ -24,16 +24,18 @@ async def test_join_command_success(join_cog, mock_channel, mock_guild, bot, moc
24 ctx.author = mock_user 24 ctx.author = mock_user
25 25
26 mock_voice_channel = MagicMock() 26 mock_voice_channel = MagicMock()
27 mock_voice = MagicMock()
28 mock_voice_channel.connect = AsyncMock(return_value=mock_voice)
29
30 ctx.author.voice = MagicMock() 27 ctx.author.voice = MagicMock()
31 ctx.author.voice.channel = mock_voice_channel 28 ctx.author.voice.channel = mock_voice_channel
32 29
33 with patch.object(mock_voice_channel, 'connect', new_callable=AsyncMock, return_value=mock_voice): 30 with patch('cogs.music.join.get_voice_manager') as mock_get_vm:
31 mock_vm = MagicMock()
32 mock_vm.connect = AsyncMock()
33 mock_get_vm.return_value = mock_vm
34
34 with patch.object(ctx, 'respond', new_callable=AsyncMock): 35 with patch.object(ctx, 'respond', new_callable=AsyncMock):
35 with patch.object(ctx.interaction, 'delete_original_response', new_callable=AsyncMock): 36 with patch.object(ctx.interaction, 'delete_original_response', new_callable=AsyncMock):
36 await join_cog.join.callback(join_cog, ctx) 37 await join_cog.join.callback(join_cog, ctx)
38 mock_vm.connect.assert_called_once_with(mock_voice_channel)
37 39
38 40
39@pytest.mark.asyncio 41@pytest.mark.asyncio
@@ -42,12 +44,13 @@ async def test_stop_command_success(stop_cog, mock_channel, mock_guild, bot, moc
42 ctx.user = mock_user 44 ctx.user = mock_user
43 ctx.author = mock_user 45 ctx.author = mock_user
44 46
45 mock_voice_client = MagicMock() 47 with patch('cogs.music.stop.get_voice_manager') as mock_get_vm:
46 mock_voice_client.disconnect = AsyncMock() 48 mock_vm = MagicMock()
47 ctx.voice_client = mock_voice_client 49 mock_vm.disconnect = AsyncMock()
50 mock_get_vm.return_value = mock_vm
48 51
49 with patch.object(ctx, 'respond', new_callable=AsyncMock): 52 with patch.object(ctx, 'respond', new_callable=AsyncMock):
50 with patch.object(ctx.interaction, 'delete_original_response', new_callable=AsyncMock): 53 with patch.object(ctx.interaction, 'delete_original_response', new_callable=AsyncMock):
51 await stop_cog.stop.callback(stop_cog, ctx) 54 await stop_cog.stop.callback(stop_cog, ctx)
52 55
53 mock_voice_client.disconnect.assert_called_once() 56 mock_vm.disconnect.assert_called_once_with(mock_guild)