Example #1
0
async def test_is_allowed_to_change_colour_false(utils_cog):
    await dpytest.message(KoalaBot.COMMAND_PREFIX + "store_ctx")
    ctx: commands.Context = utils_cog.get_last_ctx()
    roles = await make_list_of_roles(ctx.guild, 1)
    role = roles[0]
    DBManager.add_colour_change_role_perms(ctx.guild.id, role.id)
    assert not ColourRole.is_allowed_to_change_colour(ctx)
Example #2
0
async def test_is_allowed_to_change_colour_true():
    await dpytest.message(KoalaBot.COMMAND_PREFIX + "store_ctx")
    ctx: commands.Context = utils_cog.get_last_ctx()
    roles = await make_list_of_roles(ctx.guild, 1)
    role = roles[0]
    member: discord.Member = ctx.author
    DBManager.add_colour_change_role_perms(ctx.guild.id, role.id)
    await member.add_roles(role)
    assert ColourRole.is_allowed_to_change_colour(ctx)
Example #3
0
def setup_funsction():
    """ setup any state specific to the execution of the given module."""
    global role_colour_cog
    global utils_cog
    bot = commands.Bot(command_prefix=KoalaBot.COMMAND_PREFIX)
    role_colour_cog = ColourRole.ColourRole(bot)
    utils_cog = TestUtilsCog.TestUtilsCog(bot)
    bot.add_cog(role_colour_cog)
    bot.add_cog(utils_cog)
    dpytest.configure(bot)
    print("Tests starting")
Example #4
0
def role_colour_cog(bot):
    role_colour_cog = ColourRole.ColourRole(bot)
    bot.add_cog(role_colour_cog)
    dpytest.configure(bot)
    print("Tests starting")
    return role_colour_cog
Example #5
0
async def test_is_allowed_to_change_colour_no_guild_roles(utils_cog):
    await dpytest.message(KoalaBot.COMMAND_PREFIX + "store_ctx")
    ctx: commands.Context = utils_cog.get_last_ctx()
    assert not ColourRole.is_allowed_to_change_colour(ctx)