test_commands.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import pytest
  2. import discord
  3. import myanimebot.commands as commands
  4. import myanimebot.globals as globals
  5. from myanimebot.discord import MyAnimeBot
  6. import discord.ext.test as dpytest
  7. @pytest.fixture
  8. def bot(request, event_loop):
  9. ''' Create our mock bot to be used for testing purposes '''
  10. intents = discord.Intents.default()
  11. intents.members = True
  12. b = MyAnimeBot(globals.prefix, loop=event_loop, intents=intents)
  13. globals.client = b
  14. dpytest.configure(b)
  15. return b
  16. @pytest.mark.asyncio
  17. async def test_about_cmd(bot):
  18. await dpytest.message("{}about".format(globals.prefix))
  19. embed = discord.Embed(title="***MyAnimeBot Commands***", colour=0xEED000)
  20. embed.title = "MyAnimeBot version {} by Penta & lulu".format(globals.VERSION)
  21. embed.colour = 0xEED000
  22. embed.description = """MyAnimeBot checks MyAnimeList and Anilist profiles for specified users, and send a message for every new activities found.
  23. More help with the **{} help** command.
  24. Check our GitHub page for more informations: https://github.com/Penta/MyAnimeBot
  25. """.format(globals.prefix)
  26. dpytest.verify_embed(embed=embed)
  27. await dpytest.empty_queue()
  28. @pytest.mark.asyncio
  29. async def test_help_cmd(bot):
  30. await dpytest.message("{}help".format(globals.prefix))
  31. embed = discord.Embed(title="***MyAnimeBot Commands***", colour=0xEED000)
  32. embed.add_field(name="`here`", value="Register this channel. The bot will send new activities on registered channels.")
  33. embed.add_field(name="`stop`", value="Un-register this channel. The bot will now stop sending new activities for this channel.")
  34. embed.add_field(name="`info [mal|ani]`", value="Get the registered users for this server. Users can be filtered by specifying a service.")
  35. embed.add_field(name="`add {mal|ani} <user>`", value="Register a user for a specific service.\nEx: `add mal MyUser`")
  36. embed.add_field(name="`delete {mal|ani} <user>`", value="Remove a user for a specific service.\nEx: `delete ani MyUser`")
  37. embed.add_field(name="`role <@discord_role>`", value="Specify a role that is able to manage the bot.\nEx: `role @Moderator`, `role @everyone`")
  38. embed.add_field(name="`top`", value="Show statistics for this server.")
  39. embed.add_field(name="`ping`", value="Ping the bot.")
  40. embed.add_field(name="`about`", value="Get some information about this bot")
  41. dpytest.verify_embed(embed=embed)
  42. await dpytest.empty_queue()
  43. @pytest.mark.asyncio
  44. async def test_ping_cmd(bot):
  45. await dpytest.message("{}ping".format(globals.prefix))
  46. dpytest.verify_message(text="pong", contains=True)
  47. await dpytest.empty_queue()