Skip to content

Commit 331f205

Browse files
committed
Add Test Cases
1 parent 7e5c491 commit 331f205

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

intbot/core/bot/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async def close(ctx):
6666

6767
# Send notification to the thread
6868
await channel.send(f"# This was marked as done by {author.mention}")
69-
69+
7070
# We need to archive after adding tags in case it was a forum.
7171
await channel.edit(archived=True)
7272

intbot/tests/test_bot/test_main.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pytest
88
from asgiref.sync import sync_to_async
9-
from core.bot.main import ping, poll_database, qlen, source, version, wiki
9+
from core.bot.main import ping, poll_database, qlen, source, version, wiki, close
1010
from core.models import DiscordMessage
1111
from django.utils import timezone
1212

@@ -100,6 +100,24 @@ async def test_wiki_command():
100100
suppress_embeds=True,
101101
)
102102

103+
@pytest.mark.asyncio
104+
async def test_close_command():
105+
# Mock context
106+
ctx = AsyncMock()
107+
ctx.channel = discord.Thread()
108+
ctx.channel.parent = discord.ForumChannel()
109+
ctx.author = discord.Member()
110+
ctx.author.mention = "TestUser"
111+
112+
# Call the command
113+
await close(ctx)
114+
115+
# Assert that the command sent the expected message
116+
ctx.send.assert_called_once_with(
117+
"# This was marked as done by {ctx.author.mention}",
118+
suppress_embeds=True,
119+
)
120+
103121

104122
@pytest.mark.asyncio
105123
async def test_version_command():

0 commit comments

Comments
 (0)