aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cogs/test_music_join.py
diff options
context:
space:
mode:
authorsalmonik <raisersoft@proton.me>2026-04-18 16:24:42 +0200
committersalmonik <raisersoft@proton.me>2026-04-18 16:24:42 +0200
commit857a7364ddb9b10529593c5e9c3578eb95c1da9b (patch)
treecc160ed8685039fcb08663226395fb97d78fcea6 /tests/cogs/test_music_join.py
parentadd support for x^2+y^2=0,4 and alike (diff)
downloadsenator-sperma-857a7364ddb9b10529593c5e9c3578eb95c1da9b.tar.gz
senator-sperma-857a7364ddb9b10529593c5e9c3578eb95c1da9b.zip
add a test suite
Signed-off-by: salmonik <raisersoft@proton.me>
Diffstat (limited to '')
-rw-r--r--tests/cogs/test_music_join.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/cogs/test_music_join.py b/tests/cogs/test_music_join.py
new file mode 100644
index 0000000..5fc66f6
--- /dev/null
+++ b/tests/cogs/test_music_join.py
@@ -0,0 +1,53 @@
1import pytest
2from unittest.mock import AsyncMock, patch, MagicMock
3from tests.conftest import MockApplicationContext
4
5
6@pytest.fixture
7def join_cog(bot):
8 from cogs.music.join import Join
9 cog = Join(bot)
10 return cog
11
12
13@pytest.fixture
14def stop_cog(bot):
15 from cogs.music.stop import Stop
16 cog = Stop(bot)
17 return cog
18
19
20@pytest.mark.asyncio
21async def test_join_command_success(join_cog, mock_channel, mock_guild, bot, mock_user):
22 ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild)
23 ctx.user = mock_user
24 ctx.author = mock_user
25
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()
31 ctx.author.voice.channel = mock_voice_channel
32
33 with patch.object(mock_voice_channel, 'connect', new_callable=AsyncMock, return_value=mock_voice):
34 with patch.object(ctx, 'respond', new_callable=AsyncMock):
35 with patch.object(ctx.interaction, 'delete_original_response', new_callable=AsyncMock):
36 await join_cog.join.callback(join_cog, ctx)
37
38
39@pytest.mark.asyncio
40async def test_stop_command_success(stop_cog, mock_channel, mock_guild, bot, mock_user):
41 ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild)
42 ctx.user = mock_user
43 ctx.author = mock_user
44
45 mock_voice_client = MagicMock()
46 mock_voice_client.disconnect = AsyncMock()
47 ctx.voice_client = mock_voice_client
48
49 with patch.object(ctx, 'respond', new_callable=AsyncMock):
50 with patch.object(ctx.interaction, 'delete_original_response', new_callable=AsyncMock):
51 await stop_cog.stop.callback(stop_cog, ctx)
52
53 mock_voice_client.disconnect.assert_called_once() \ No newline at end of file