diff options
| author | salmonik <salmonik@noreply.codeberg.org> | 2026-04-19 18:10:09 +0200 |
|---|---|---|
| committer | salmonik <salmonik@noreply.codeberg.org> | 2026-04-19 18:10:09 +0200 |
| commit | f8e1cf36e1efa0602bf2e450835f2a67654762a6 (patch) | |
| tree | fe6b12226d7eebe2a0dc6525de3414d0c3718cc8 /tests/cogs/test_say.py | |
| parent | add support for x^2+y^2=0,4 and alike (diff) | |
| parent | fix: proper aiohttp async context manager mocking in test (diff) | |
| download | senator-sperma-f8e1cf36e1efa0602bf2e450835f2a67654762a6.tar.gz senator-sperma-f8e1cf36e1efa0602bf2e450835f2a67654762a6.zip | |
Merge pull request 'massive changes' (#3) from dev into main
Reviewed-on: https://codeberg.org/salmonik/senator-sperma/pulls/3
stable enough
Diffstat (limited to '')
| -rw-r--r-- | tests/cogs/test_say.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/cogs/test_say.py b/tests/cogs/test_say.py new file mode 100644 index 0000000..13cad40 --- /dev/null +++ b/tests/cogs/test_say.py | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | import pytest | ||
| 2 | from unittest.mock import AsyncMock, patch | ||
| 3 | from cogs.say import Say | ||
| 4 | from tests.conftest import MockApplicationContext | ||
| 5 | |||
| 6 | |||
| 7 | @pytest.fixture | ||
| 8 | def say_cog(bot): | ||
| 9 | cog = Say(bot) | ||
| 10 | return cog | ||
| 11 | |||
| 12 | |||
| 13 | @pytest.mark.asyncio | ||
| 14 | async def test_say_command(say_cog, mock_channel, mock_guild, bot): | ||
| 15 | ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) | ||
| 16 | |||
| 17 | with patch.object(ctx, 'send', new_callable=AsyncMock) as mock_send: | ||
| 18 | await say_cog.say.callback(say_cog, ctx, "Hello World") | ||
| 19 | mock_send.assert_called_once_with(content="Hello World") | ||
| 20 | |||
| 21 | |||
| 22 | @pytest.mark.asyncio | ||
| 23 | async def test_say_command_empty_text(say_cog, mock_channel, mock_guild, bot): | ||
| 24 | ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) | ||
| 25 | |||
| 26 | with patch.object(ctx, 'send', new_callable=AsyncMock) as mock_send: | ||
| 27 | await say_cog.say.callback(say_cog, ctx, "") | ||
| 28 | mock_send.assert_called_once_with(content="") | ||
| 29 | |||
| 30 | |||
| 31 | @pytest.mark.asyncio | ||
| 32 | async def test_say_command_long_text(say_cog, mock_channel, mock_guild, bot): | ||
| 33 | ctx = MockApplicationContext(bot=bot, channel=mock_channel, guild=mock_guild) | ||
| 34 | long_text = "A" * 2000 | ||
| 35 | |||
| 36 | with patch.object(ctx, 'send', new_callable=AsyncMock) as mock_send: | ||
| 37 | await say_cog.say.callback(say_cog, ctx, long_text) | ||
| 38 | mock_send.assert_called_once_with(content=long_text) | ||
