Beispiel #1
0
def test_is_mod_with_member_object_and_authorised_caller(ctx, loop):
    """
    Test is_mod() with member object when caller is admin.

    Should return guild_permissions.administrator (== True).
    """
    ctx.author.guild_permissions.administrator = True
    result = loop.run_until_complete(checks.is_mod(ctx.author))

    assert result, "is_mod() should return True for admin"
Beispiel #2
0
    def test_is_mod_with_member_object_and_unauthorised_caller(self):
        """
        Test is_mod() with member object when caller is NOT admin.

        Should return guild_permissions.administrator (== False).
        """
        self.member.guild_permissions.administrator = False
        result = self.loop.run_until_complete(checks.is_mod(self.member))

        self.assertFalse(result)
Beispiel #3
0
    def test_is_mod_with_ctx_object_and_authorised_caller(self):
        """
        Test is_mod() with context object when caller is admin.

        Should return guild_permissions.administrator (== True).
        """
        self.member.guild_permissions.administrator = True
        result = self.loop.run_until_complete(checks.is_mod(self.ctx))

        self.assertTrue(result)
Beispiel #4
0
def test_is_mod_with_ctx_object_and_unauthorised_caller_in_dm(ctx, loop):
    """
    Test is_mod() with context object when caller is NOT admin.

    Should return guild_permissions.administrator (== False).
    """
    ctx.guild = None
    result = loop.run_until_complete(checks.is_mod(ctx))

    ctx.send.assert_called_with(
        "Don't you try to sneak into my DMs and mod me!")

    assert not result, "is_mod() should return False for in DMs"
Beispiel #5
0
def test_is_mod_with_ctx_object_and_unauthorised_caller(ctx, loop):
    """
    Test is_mod() with context object when caller is NOT admin.

    Should return guild_permissions.administrator (== False).
    """
    ctx.author.guild_permissions.administrator = False
    result = loop.run_until_complete(checks.is_mod(ctx))

    ctx.send.assert_called_with(
        "@member Only mods are allowed to use that command.")

    assert not result, "is_mod() should return False for non-admin"