From cd8ed8bc5793985df2c1692072a932ceee517b95 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 8 Jul 2026 02:13:35 +0200 Subject: OPEN THE RUST GATES Signed-off-by: salmonik --- tests/cogs/test_qr.py | 75 --------------------------------------------------- 1 file changed, 75 deletions(-) delete mode 100644 tests/cogs/test_qr.py (limited to 'tests/cogs/test_qr.py') diff --git a/tests/cogs/test_qr.py b/tests/cogs/test_qr.py deleted file mode 100644 index b5cb31f..0000000 --- a/tests/cogs/test_qr.py +++ /dev/null @@ -1,75 +0,0 @@ -import pytest -from unittest.mock import AsyncMock, patch, MagicMock, mock_open -import os -from cogs.qr import QR -from conftest import MockApplicationContext - - -@pytest.fixture -def qr_cog(bot): - cog = QR(bot) - return cog - - -@pytest.fixture -def mock_temp_file(): - with patch('tempfile.NamedTemporaryFile') as mock: - mock_file = MagicMock() - mock_file.name = "/tmp/test_qr.png" - mock.return_value = mock_file - yield mock_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): - with patch('os.unlink'): - await qr_cog.qr.callback(qr_cog, ctx, text="https://example.com") - mock_generate.assert_called_once() - mock_respond.assert_called_once() - - -@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): - await qr_cog.qr.callback(qr_cog, ctx, text="") - mock_respond.assert_called_once() - - -@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) - mock_respond.assert_called_once() - args = mock_respond.call_args - assert "nie jest dostępne" in str(args) or "not available" in str(args).lower() - - -@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() -- cgit v1.2.3