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_music_play.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_music_play.py')
| -rw-r--r-- | tests/cogs/test_music_play.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/tests/cogs/test_music_play.py b/tests/cogs/test_music_play.py index abdd81c..e720c9a 100644 --- a/tests/cogs/test_music_play.py +++ b/tests/cogs/test_music_play.py | |||
| @@ -22,7 +22,7 @@ def loop_cog(bot): | |||
| 22 | @pytest.mark.asyncio | 22 | @pytest.mark.asyncio |
| 23 | async def test_create_search_embed_empty(play_commands_cog): | 23 | async def test_create_search_embed_empty(play_commands_cog): |
| 24 | embed, view = await play_commands_cog._create_search_embed([]) | 24 | embed, view = await play_commands_cog._create_search_embed([]) |
| 25 | 25 | ||
| 26 | assert embed.title == "Wyniki wyszukiwania" | 26 | assert embed.title == "Wyniki wyszukiwania" |
| 27 | assert len(view.children) == 0 | 27 | assert len(view.children) == 0 |
| 28 | 28 | ||
| @@ -33,9 +33,9 @@ async def test_create_search_embed_with_candidates(play_commands_cog): | |||
| 33 | "https://example.com/test1.mp3", | 33 | "https://example.com/test1.mp3", |
| 34 | "https://example.com/test2.mp3" | 34 | "https://example.com/test2.mp3" |
| 35 | ] | 35 | ] |
| 36 | 36 | ||
| 37 | embed, view = await play_commands_cog._create_search_embed(candidates) | 37 | embed, view = await play_commands_cog._create_search_embed(candidates) |
| 38 | 38 | ||
| 39 | assert embed.title == "Wyniki wyszukiwania" | 39 | assert embed.title == "Wyniki wyszukiwania" |
| 40 | assert len(embed.fields) == 2 | 40 | assert len(embed.fields) == 2 |
| 41 | 41 | ||
| @@ -43,7 +43,7 @@ async def test_create_search_embed_with_candidates(play_commands_cog): | |||
| 43 | @pytest.mark.asyncio | 43 | @pytest.mark.asyncio |
| 44 | async def test_play_command_no_file_or_search(play_commands_cog, mock_channel, mock_guild, bot): | 44 | async def test_play_command_no_file_or_search(play_commands_cog, mock_channel, mock_guild, bot): |
| 45 | ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) | 45 | ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) |
| 46 | 46 | ||
| 47 | with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: | 47 | with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: |
| 48 | await play_commands_cog.play.callback(play_commands_cog, ctx, melodia=None, file=None, compressed=False) | 48 | await play_commands_cog.play.callback(play_commands_cog, ctx, melodia=None, file=None, compressed=False) |
| 49 | mock_respond.assert_called_once() | 49 | mock_respond.assert_called_once() |
| @@ -54,10 +54,10 @@ async def test_play_command_no_file_or_search(play_commands_cog, mock_channel, m | |||
| 54 | @pytest.mark.asyncio | 54 | @pytest.mark.asyncio |
| 55 | async def test_play_command_both_file_and_search(play_commands_cog, mock_channel, mock_guild, bot): | 55 | async def test_play_command_both_file_and_search(play_commands_cog, mock_channel, mock_guild, bot): |
| 56 | ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) | 56 | ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) |
| 57 | 57 | ||
| 58 | mock_file = MagicMock() | 58 | mock_file = MagicMock() |
| 59 | mock_file.filename = "test.mp3" | 59 | mock_file.filename = "test.mp3" |
| 60 | 60 | ||
| 61 | with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: | 61 | with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: |
| 62 | await play_commands_cog.play.callback(play_commands_cog, ctx, melodia="test", file=mock_file, compressed=False) | 62 | await play_commands_cog.play.callback(play_commands_cog, ctx, melodia="test", file=mock_file, compressed=False) |
| 63 | mock_respond.assert_called_once() | 63 | mock_respond.assert_called_once() |
| @@ -80,7 +80,7 @@ async def test_loop_command_toggle_on(loop_cog, mock_channel, mock_guild, bot, m | |||
| 80 | ctx.user = mock_user | 80 | ctx.user = mock_user |
| 81 | ctx.author = mock_user | 81 | ctx.author = mock_user |
| 82 | ctx.guild.id = 123 | 82 | ctx.guild.id = 123 |
| 83 | 83 | ||
| 84 | with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: | 84 | with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: |
| 85 | await loop_cog.loop.callback(loop_cog, ctx) | 85 | await loop_cog.loop.callback(loop_cog, ctx) |
| 86 | mock_respond.assert_called_once() | 86 | mock_respond.assert_called_once() |
| @@ -94,11 +94,11 @@ async def test_loop_command_toggle_off(loop_cog, mock_channel, mock_guild, bot, | |||
| 94 | ctx.user = mock_user | 94 | ctx.user = mock_user |
| 95 | ctx.author = mock_user | 95 | ctx.author = mock_user |
| 96 | ctx.guild.id = 456 | 96 | ctx.guild.id = 456 |
| 97 | 97 | ||
| 98 | loop_cog.set_looping(456, True) | 98 | loop_cog.set_looping(456, True) |
| 99 | 99 | ||
| 100 | with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: | 100 | with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: |
| 101 | await loop_cog.loop.callback(loop_cog, ctx) | 101 | await loop_cog.loop.callback(loop_cog, ctx) |
| 102 | mock_respond.assert_called_once() | 102 | mock_respond.assert_called_once() |
| 103 | args = mock_respond.call_args | 103 | args = mock_respond.call_args |
| 104 | assert "wyłączony" in str(args) \ No newline at end of file | 104 | assert "wyłączony" in str(args) |
