mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
* Readd work due to redoing branch * [modlog] Move to core and start work on separating it from cogs * More work on modlog separation * [Core] Finish logic for modlog, do docstrings, async getters * [Core] Add stuff to dunder all * [Docs] Add mod log docs * [Core] Move away from dunder str for Case class * [Docs] don't need to doc special members in modlog docs * More on mod log to implement commands * More work on Mod * [Mod] compatibility with async getters * [Tests] start tests for mod * [Tests] attempted fix * [Tests] mod tests passing now! * [ModLog] update for i18n * modlog.pot -> messages.pot * [Mod] i18n * fix getting admin/mod roles * Fix doc building * [Mod/Modlog] redo imports * [Tests] fix imports in mod tests * [Mod] fix logger problem * [Mod] cleanup errors * A couple of bug fixes Async getters, some old `config.set` syntax * Filter ignores private channels * Fix softban Was still relying on default channels * Actually ignore private channels * Add check for ignored channels * Fix logic for ignore check * Send confirm messages before making case * Pass in guild when setting modlog * Thanks autocomplete * Maintain all data for case * Properly ignore softbans in events * [Mod] bugfixes * [Mod] more changes * [ModLog] timestamp change * [Mod] split filter and cleanup to their own cogs + regen messages.pot * [Cleanup] change logic * [Cleanup] increase limit for channel.history * [Mod] await getter in modset banmentionspam * [Mod] attempt duplicate modlog message fix * [Mod] get_user -> get_user_info * [Modlog] change reason command so the case author can edit their cases (#806) * [Modlog] make reason command guild only * [Modlog] clarify the reason command's help * [Mod] package path changes + numpy style docstrings for modlog * [Mod] change ban and unban events to need view audit log perms to find/create a case * [Modlog] refactoring * [Filter] add autoban feature * [Mod] update case types + event changes * [Mod/Modlog] fix tests, fix permissions things * [Docs] fix up modlog docs * Regenerate messages.pot
53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
import pytest
|
|
|
|
|
|
@pytest.fixture
|
|
def mod(config):
|
|
from redbot.core import Config
|
|
|
|
Config.get_conf = lambda *args, **kwargs: config
|
|
|
|
from redbot.core import modlog
|
|
|
|
modlog._register_defaults()
|
|
return modlog
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_modlog_register_casetype(mod, ctx):
|
|
ct = {
|
|
"name": "ban",
|
|
"default_setting": True,
|
|
"image": ":hammer:",
|
|
"case_str": "Ban",
|
|
"audit_type": "ban"
|
|
}
|
|
casetype = await mod.register_casetype(**ct)
|
|
assert casetype is not None
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_modlog_case_create(mod, ctx, member_factory):
|
|
from datetime import datetime as dt
|
|
usr = member_factory.get()
|
|
guild = ctx.guild
|
|
case_type = "ban"
|
|
moderator = ctx.author
|
|
reason = "Test 12345"
|
|
created_at = dt.utcnow()
|
|
case = await mod.create_case(
|
|
guild, created_at, case_type, usr, moderator, reason
|
|
)
|
|
assert case is not None
|
|
assert case.user == usr
|
|
assert case.action_type == case_type
|
|
assert case.moderator == moderator
|
|
assert case.reason == reason
|
|
assert case.created_at == int(created_at.timestamp())
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_modlog_set_modlog_channel(mod, ctx):
|
|
await mod.set_modlog_channel(ctx.guild, ctx.channel)
|
|
assert await mod.get_modlog_channel(ctx.guild) == ctx.channel.id
|