Skip to content

Commit 9628b9f

Browse files
committed
Add test case when the command doesn't work
1 parent 6e0e8b7 commit 9628b9f

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

intbot/core/bot/main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ async def close(ctx):
6969

7070
# We need to archive after adding tags in case it was a forum.
7171
await channel.edit(archived=True)
72+
else:
73+
# Remove command message
74+
await ctx.message.delete()
75+
76+
await channel.send("The !close command is intended to be used inside a thread/post",
77+
suppress_embeds=True,
78+
delete_after=5)
7279

7380

7481

intbot/tests/test_bot/test_main.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ async def test_wiki_command():
102102
)
103103

104104
@pytest.mark.asyncio
105-
async def test_close_command():
105+
async def test_close_command_working():
106106
# Mock context
107107
ctx = AsyncMock()
108108
ctx.channel = AsyncMock()
@@ -118,6 +118,23 @@ async def test_close_command():
118118
suppress_embeds=True,
119119
)
120120

121+
@pytest.mark.asyncio
122+
async def test_close_command_notworking():
123+
# Mock context
124+
ctx = AsyncMock()
125+
ctx.channel = AsyncMock()
126+
ctx.message.author = AsyncMock()
127+
128+
# Call the command
129+
await close(ctx)
130+
131+
# Assert that the command sent the expected message
132+
ctx.channel.send.assert_called_once_with(
133+
"The !close command is intended to be used inside a thread/post",
134+
suppress_embeds=True,
135+
delete_after=5
136+
)
137+
121138

122139
@pytest.mark.asyncio
123140
async def test_version_command():

0 commit comments

Comments
 (0)