import pytest from unittest.mock import AsyncMock, patch from cogs.say import Say from conftest import MockApplicationContext @pytest.fixture def say_cog(bot): cog = Say(bot) return cog @pytest.mark.asyncio async def test_say_command(say_cog, mock_channel, mock_guild, bot): ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) with patch.object(ctx, 'send', new_callable=AsyncMock) as mock_send: await say_cog.say.callback(say_cog, ctx, "Hello World") mock_send.assert_called_once_with(content="Hello World") @pytest.mark.asyncio async def test_say_command_empty_text(say_cog, mock_channel, mock_guild, bot): ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) with patch.object(ctx, 'send', new_callable=AsyncMock) as mock_send: await say_cog.say.callback(say_cog, ctx, "") mock_send.assert_called_once_with(content="") @pytest.mark.asyncio async def test_say_command_long_text(say_cog, mock_channel, mock_guild, bot): ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) long_text = "A" * 2000 with patch.object(ctx, 'send', new_callable=AsyncMock) as mock_send: await say_cog.say.callback(say_cog, ctx, long_text) mock_send.assert_called_once_with(content=long_text)