From b343381fea3eab26e334a1b3bba202d715f9ea2e Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 19 Apr 2026 15:44:33 +0200 Subject: test: improve test assertions and edge cases --- tests/cogs/test_music_play.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'tests/cogs/test_music_play.py') 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): @pytest.mark.asyncio async def test_create_search_embed_empty(play_commands_cog): embed, view = await play_commands_cog._create_search_embed([]) - + assert embed.title == "Wyniki wyszukiwania" assert len(view.children) == 0 @@ -33,9 +33,9 @@ async def test_create_search_embed_with_candidates(play_commands_cog): "https://example.com/test1.mp3", "https://example.com/test2.mp3" ] - + embed, view = await play_commands_cog._create_search_embed(candidates) - + assert embed.title == "Wyniki wyszukiwania" assert len(embed.fields) == 2 @@ -43,7 +43,7 @@ async def test_create_search_embed_with_candidates(play_commands_cog): @pytest.mark.asyncio async def test_play_command_no_file_or_search(play_commands_cog, mock_channel, mock_guild, bot): ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) - + with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: await play_commands_cog.play.callback(play_commands_cog, ctx, melodia=None, file=None, compressed=False) mock_respond.assert_called_once() @@ -54,10 +54,10 @@ async def test_play_command_no_file_or_search(play_commands_cog, mock_channel, m @pytest.mark.asyncio async def test_play_command_both_file_and_search(play_commands_cog, mock_channel, mock_guild, bot): ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) - + mock_file = MagicMock() mock_file.filename = "test.mp3" - + with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: await play_commands_cog.play.callback(play_commands_cog, ctx, melodia="test", file=mock_file, compressed=False) mock_respond.assert_called_once() @@ -80,7 +80,7 @@ async def test_loop_command_toggle_on(loop_cog, mock_channel, mock_guild, bot, m ctx.user = mock_user ctx.author = mock_user ctx.guild.id = 123 - + with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: await loop_cog.loop.callback(loop_cog, ctx) mock_respond.assert_called_once() @@ -94,11 +94,11 @@ async def test_loop_command_toggle_off(loop_cog, mock_channel, mock_guild, bot, ctx.user = mock_user ctx.author = mock_user ctx.guild.id = 456 - + loop_cog.set_looping(456, True) - + with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: await loop_cog.loop.callback(loop_cog, ctx) mock_respond.assert_called_once() args = mock_respond.call_args - assert "wyłączony" in str(args) \ No newline at end of file + assert "wyłączony" in str(args) -- cgit v1.2.3