Skip to content

Commit 935de3e

Browse files
committed
Fix testing (hopefully I did it right)
1 parent df09374 commit 935de3e

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

techsupport_bot/tests/commands_tests/test_extensions_htd.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import importlib
77
from unittest.mock import AsyncMock, MagicMock, call, patch
8+
from discord.ext import commands
89

910
import discord
1011
import pytest
@@ -648,16 +649,24 @@ async def test_convertints_error(self):
648649
hextodec.convert_list_to_ints = MagicMock(side_effect=ValueError)
649650
hextodec.perform_op_on_list = MagicMock()
650651
hextodec.custom_embed_generation = MagicMock()
651-
auxiliary.send_deny_embed = AsyncMock()
652-
discord_env.context.send = AsyncMock()
652+
auxiliary.prepare_deny_embed = MagicMock()
653+
654+
# Create a MockContext with the required attributes
655+
mock_context = MagicMock(spec=commands.Context)
656+
mock_context.send = AsyncMock() # Mock the send method
657+
658+
# Set the mock context for the test
659+
discord_env.context = mock_context
653660

654661
# Step 2 - Call the function
655662
await hextodec.htd_command(discord_env.context, "test")
656663

657664
# Step 3 - Assert that everything works
658-
auxiliary.send_deny_embed.assert_called_once_with(
659-
message="Unable to convert value, are you sure it's valid?",
660-
channel=discord_env.context.channel,
665+
auxiliary.prepare_deny_embed.assert_called_once_with(
666+
message="Unable to convert value, are you sure it's valid?"
667+
)
668+
discord_env.context.send.assert_called_once_with(
669+
embed=auxiliary.prepare_deny_embed.return_value
661670
)
662671

663672
# Step 4 - Cleanup

0 commit comments

Comments
 (0)