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_math_commands.py | 55 ---------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 tests/cogs/test_math_commands.py (limited to 'tests/cogs/test_math_commands.py') diff --git a/tests/cogs/test_math_commands.py b/tests/cogs/test_math_commands.py deleted file mode 100644 index 21e9a2e..0000000 --- a/tests/cogs/test_math_commands.py +++ /dev/null @@ -1,55 +0,0 @@ -import pytest -from unittest.mock import AsyncMock, patch, MagicMock -from conftest import MockApplicationContext - - -@pytest.fixture -def math_cog(bot): - from cogs.math_commands import Math - cog = Math(bot) - return cog - - -@pytest.mark.asyncio -async def test_math_command_valid_expression(math_cog, mock_channel, mock_guild, bot): - ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) - - mock_process = MagicMock() - mock_process.returncode = 0 - mock_process.communicate = AsyncMock(return_value=(b"4", b"")) - - with patch('cogs.math_commands.asyncio.create_subprocess_exec', return_value=mock_process) as mock_subprocess: - with patch('cogs.math_commands.re.search', return_value=None): - with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: - await math_cog.math.callback(math_cog, ctx, equation="2+2") - mock_subprocess.assert_called_once() - mock_respond.assert_called_once() - - -@pytest.mark.asyncio -async def test_math_command_invalid_expression(math_cog, mock_channel, mock_guild, bot): - ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) - - with patch('cogs.math_commands.re.search', return_value=MagicMock()): - with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: - await math_cog.math.callback(math_cog, ctx, equation="eval(1)") - mock_respond.assert_called_once() - args = mock_respond.call_args - assert "Invalid" in str(args) - - -@pytest.mark.asyncio -async def test_math_command_process_error(math_cog, mock_channel, mock_guild, bot): - ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) - - mock_process = MagicMock() - mock_process.returncode = 1 - mock_process.communicate = AsyncMock(return_value=(b"", b"Error: invalid expression")) - - with patch('cogs.math_commands.asyncio.create_subprocess_exec', return_value=mock_process): - with patch('cogs.math_commands.re.search', return_value=None): - with patch.object(ctx, 'respond', new_callable=AsyncMock) as mock_respond: - await math_cog.math.callback(math_cog, ctx, equation="2++") - mock_respond.assert_called_once() - args = mock_respond.call_args - assert "error" in str(args).lower() or "Error" in str(args) -- cgit v1.2.3