From 857a7364ddb9b10529593c5e9c3578eb95c1da9b Mon Sep 17 00:00:00 2001 From: salmonik Date: Sat, 18 Apr 2026 16:24:42 +0200 Subject: add a test suite Signed-off-by: salmonik --- tests/cogs/test_say.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/cogs/test_say.py (limited to 'tests/cogs/test_say.py') diff --git a/tests/cogs/test_say.py b/tests/cogs/test_say.py new file mode 100644 index 0000000..12f2d2a --- /dev/null +++ b/tests/cogs/test_say.py @@ -0,0 +1,38 @@ +import pytest +from unittest.mock import AsyncMock, patch +from cogs.say import Say +from tests.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) \ No newline at end of file -- cgit v1.2.3