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_qr.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tests/cogs/test_qr.py') diff --git a/tests/cogs/test_qr.py b/tests/cogs/test_qr.py index f3688e3..2a132ca 100644 --- a/tests/cogs/test_qr.py +++ b/tests/cogs/test_qr.py @@ -23,7 +23,7 @@ def mock_temp_file(): @pytest.mark.asyncio async def test_qr_generate_success(qr_cog, mock_channel, mock_guild, bot, mock_temp_file): ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) - + with patch('cogs.qr.QR._generate_qr') as mock_generate: with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: with patch('os.path.exists', return_value=True): @@ -36,7 +36,7 @@ async def test_qr_generate_success(qr_cog, mock_channel, mock_guild, bot, mock_t @pytest.mark.asyncio async def test_qr_generate_empty_text(qr_cog, mock_channel, mock_guild, bot): ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) - + with patch('cogs.qr.QR._generate_qr'): with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: with patch('os.path.exists', return_value=False): @@ -47,10 +47,10 @@ async def test_qr_generate_empty_text(qr_cog, mock_channel, mock_guild, bot): @pytest.mark.asyncio async def test_qr_decode_not_available(qr_cog, mock_channel, mock_guild, bot): ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) - + mock_attachment = MagicMock() mock_attachment.url = "https://example.com/qr.png" - + with patch('cogs.qr._ensure_qr', return_value=False): with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: await qr_cog.decode.callback(qr_cog, ctx, image=mock_attachment) @@ -62,14 +62,14 @@ async def test_qr_decode_not_available(qr_cog, mock_channel, mock_guild, bot): @pytest.mark.asyncio async def test_qr_decode_download_failure(qr_cog, mock_channel, mock_guild, bot): ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) - + mock_attachment = MagicMock() mock_attachment.url = "https://example.com/qr.png" - + with patch('cogs.qr._ensure_qr', return_value=True): with patch.object(qr_cog, '_download_image', return_value=None): with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: await qr_cog.decode.callback(qr_cog, ctx, image=mock_attachment) mock_respond.assert_called_once() args = mock_respond.call_args - assert "Nie udało się" in str(args) or "failed" in str(args).lower() \ No newline at end of file + assert "Nie udało się" in str(args) or "failed" in str(args).lower() -- cgit v1.2.3