Skip to content

Commit

Permalink
Add test for subgroups
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorukyum committed Mar 31, 2024
1 parent a47b598 commit 05860a8
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,33 @@ async def test_command(self, ctx):
assert test_command.name == "test_command"
assert test_command.parent == group


@run_test
def test_subgroup():
bot = Bot()

class FirstCog(discord.Cog):
group = discord.SlashCommandGroup("group")
subgroup = group.create_subgroup("subgroup")

@subgroup.command()
async def dummy(self, ctx):
await ctx.respond("I am a dummy command.")

class SecondCog(discord.Cog):
@subcommand("group subgroup")
@discord.slash_command()
async def test_command(self, ctx):
await ctx.respond("I am another dummy command.")

bot.add_cog(FirstCog())
bot.add_cog(SecondCog())

group = bot.pending_application_commands[0]
assert isinstance(group, discord.SlashCommandGroup)
subgroup = group.subcommands[-1]
assert isinstance(subgroup, discord.SlashCommandGroup)
assert subgroup.name == "subgroup"
test_command = subgroup.subcommands[-1]
assert test_command.name == "test_command"
assert test_command.parent == subgroup

0 comments on commit 05860a8

Please sign in to comment.