diff options
Diffstat (limited to '')
| -rw-r--r-- | tests/cogs/test_qr.py | 14 |
1 files changed, 7 insertions, 7 deletions
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(): | |||
| 23 | @pytest.mark.asyncio | 23 | @pytest.mark.asyncio |
| 24 | async def test_qr_generate_success(qr_cog, mock_channel, mock_guild, bot, mock_temp_file): | 24 | async def test_qr_generate_success(qr_cog, mock_channel, mock_guild, bot, mock_temp_file): |
| 25 | ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) | 25 | ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) |
| 26 | 26 | ||
| 27 | with patch('cogs.qr.QR._generate_qr') as mock_generate: | 27 | with patch('cogs.qr.QR._generate_qr') as mock_generate: |
| 28 | with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: | 28 | with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: |
| 29 | with patch('os.path.exists', return_value=True): | 29 | 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 | |||
| 36 | @pytest.mark.asyncio | 36 | @pytest.mark.asyncio |
| 37 | async def test_qr_generate_empty_text(qr_cog, mock_channel, mock_guild, bot): | 37 | async def test_qr_generate_empty_text(qr_cog, mock_channel, mock_guild, bot): |
| 38 | ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) | 38 | ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) |
| 39 | 39 | ||
| 40 | with patch('cogs.qr.QR._generate_qr'): | 40 | with patch('cogs.qr.QR._generate_qr'): |
| 41 | with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: | 41 | with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: |
| 42 | with patch('os.path.exists', return_value=False): | 42 | 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): | |||
| 47 | @pytest.mark.asyncio | 47 | @pytest.mark.asyncio |
| 48 | async def test_qr_decode_not_available(qr_cog, mock_channel, mock_guild, bot): | 48 | async def test_qr_decode_not_available(qr_cog, mock_channel, mock_guild, bot): |
| 49 | ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) | 49 | ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) |
| 50 | 50 | ||
| 51 | mock_attachment = MagicMock() | 51 | mock_attachment = MagicMock() |
| 52 | mock_attachment.url = "https://example.com/qr.png" | 52 | mock_attachment.url = "https://example.com/qr.png" |
| 53 | 53 | ||
| 54 | with patch('cogs.qr._ensure_qr', return_value=False): | 54 | with patch('cogs.qr._ensure_qr', return_value=False): |
| 55 | with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: | 55 | with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: |
| 56 | await qr_cog.decode.callback(qr_cog, ctx, image=mock_attachment) | 56 | 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): | |||
| 62 | @pytest.mark.asyncio | 62 | @pytest.mark.asyncio |
| 63 | async def test_qr_decode_download_failure(qr_cog, mock_channel, mock_guild, bot): | 63 | async def test_qr_decode_download_failure(qr_cog, mock_channel, mock_guild, bot): |
| 64 | ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) | 64 | ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) |
| 65 | 65 | ||
| 66 | mock_attachment = MagicMock() | 66 | mock_attachment = MagicMock() |
| 67 | mock_attachment.url = "https://example.com/qr.png" | 67 | mock_attachment.url = "https://example.com/qr.png" |
| 68 | 68 | ||
| 69 | with patch('cogs.qr._ensure_qr', return_value=True): | 69 | with patch('cogs.qr._ensure_qr', return_value=True): |
| 70 | with patch.object(qr_cog, '_download_image', return_value=None): | 70 | with patch.object(qr_cog, '_download_image', return_value=None): |
| 71 | with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: | 71 | with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: |
| 72 | await qr_cog.decode.callback(qr_cog, ctx, image=mock_attachment) | 72 | await qr_cog.decode.callback(qr_cog, ctx, image=mock_attachment) |
| 73 | mock_respond.assert_called_once() | 73 | mock_respond.assert_called_once() |
| 74 | args = mock_respond.call_args | 74 | args = mock_respond.call_args |
| 75 | assert "Nie udało się" in str(args) or "failed" in str(args).lower() \ No newline at end of file | 75 | assert "Nie udało się" in str(args) or "failed" in str(args).lower() |
