diff options
author | 2021-07-07 22:24:21 +0300 | |
---|---|---|
committer | 2021-07-07 22:24:21 +0300 | |
commit | fb9cbe434fc4531d117e6b8bdbd778dc4e9803a5 (patch) | |
tree | 93a924e616ca83438175d6e18f1126996f1f7738 | |
parent | Disable more filters in jam channels (#1675) (diff) |
Create events ext, prepare jams cog for file split
-rw-r--r-- | bot/exts/events/__init__.py | 0 | ||||
-rw-r--r-- | bot/exts/events/code_jams/__init__.py | 8 | ||||
-rw-r--r-- | bot/exts/events/code_jams/_cog.py (renamed from bot/exts/utils/jams.py) | 0 | ||||
-rw-r--r-- | bot/exts/filters/antimalware.py | 2 | ||||
-rw-r--r-- | bot/exts/filters/antispam.py | 2 | ||||
-rw-r--r-- | bot/exts/filters/filtering.py | 2 | ||||
-rw-r--r-- | tests/bot/exts/events/__init__.py | 0 | ||||
-rw-r--r-- | tests/bot/exts/events/test_code_jams.py (renamed from tests/bot/exts/utils/test_jams.py) | 16 |
8 files changed, 19 insertions, 11 deletions
diff --git a/bot/exts/events/__init__.py b/bot/exts/events/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/bot/exts/events/__init__.py diff --git a/bot/exts/events/code_jams/__init__.py b/bot/exts/events/code_jams/__init__.py new file mode 100644 index 000000000..16e81e365 --- /dev/null +++ b/bot/exts/events/code_jams/__init__.py @@ -0,0 +1,8 @@ +from bot.bot import Bot + + +def setup(bot: Bot) -> None: + """Load the CodeJams cog.""" + from bot.exts.events.code_jams._cog import CodeJams + + bot.add_cog(CodeJams(bot)) diff --git a/bot/exts/utils/jams.py b/bot/exts/events/code_jams/_cog.py index 87ae847f6..87ae847f6 100644 --- a/bot/exts/utils/jams.py +++ b/bot/exts/events/code_jams/_cog.py diff --git a/bot/exts/filters/antimalware.py b/bot/exts/filters/antimalware.py index 4c4836c88..3f6213db3 100644 --- a/bot/exts/filters/antimalware.py +++ b/bot/exts/filters/antimalware.py @@ -7,7 +7,7 @@ from discord.ext.commands import Cog from bot.bot import Bot from bot.constants import Channels, Filter, URLs -from bot.exts.utils.jams import CATEGORY_NAME as JAM_CATEGORY_NAME +from bot.exts.events.code_jams._cog import CATEGORY_NAME as JAM_CATEGORY_NAME log = logging.getLogger(__name__) diff --git a/bot/exts/filters/antispam.py b/bot/exts/filters/antispam.py index 48c3aa5a6..124905cb4 100644 --- a/bot/exts/filters/antispam.py +++ b/bot/exts/filters/antispam.py @@ -17,8 +17,8 @@ from bot.constants import ( Guild as GuildConfig, Icons, ) from bot.converters import Duration +from bot.exts.events.code_jams._cog import CATEGORY_NAME as JAM_CATEGORY_NAME from bot.exts.moderation.modlog import ModLog -from bot.exts.utils.jams import CATEGORY_NAME as JAM_CATEGORY_NAME from bot.utils import lock, scheduling from bot.utils.messages import format_user, send_attachments diff --git a/bot/exts/filters/filtering.py b/bot/exts/filters/filtering.py index 16aaf11cf..0810425e2 100644 --- a/bot/exts/filters/filtering.py +++ b/bot/exts/filters/filtering.py @@ -19,8 +19,8 @@ from bot.constants import ( Channels, Colours, Filter, Guild, Icons, URLs ) +from bot.exts.events.code_jams._cog import CATEGORY_NAME as JAM_CATEGORY_NAME from bot.exts.moderation.modlog import ModLog -from bot.exts.utils.jams import CATEGORY_NAME as JAM_CATEGORY_NAME from bot.utils.messages import format_user from bot.utils.regex import INVITE_RE from bot.utils.scheduling import Scheduler diff --git a/tests/bot/exts/events/__init__.py b/tests/bot/exts/events/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/bot/exts/events/__init__.py diff --git a/tests/bot/exts/utils/test_jams.py b/tests/bot/exts/events/test_code_jams.py index 368a15476..d7b8aa4d2 100644 --- a/tests/bot/exts/utils/test_jams.py +++ b/tests/bot/exts/events/test_code_jams.py @@ -5,7 +5,7 @@ from discord import CategoryChannel from discord.ext.commands import BadArgument from bot.constants import Roles -from bot.exts.utils import jams +from bot.exts.events.code_jams import _cog from tests.helpers import ( MockAttachment, MockBot, MockCategoryChannel, MockContext, MockGuild, MockMember, MockRole, MockTextChannel @@ -40,7 +40,7 @@ class JamCodejamCreateTests(unittest.IsolatedAsyncioTestCase): self.command_user = MockMember([self.admin_role]) self.guild = MockGuild([self.admin_role]) self.ctx = MockContext(bot=self.bot, author=self.command_user, guild=self.guild) - self.cog = jams.CodeJams(self.bot) + self.cog = _cog.CodeJams(self.bot) async def test_message_without_attachments(self): """If no link or attachments are provided, commands.BadArgument should be raised.""" @@ -85,8 +85,8 @@ class JamCodejamCreateTests(unittest.IsolatedAsyncioTestCase): """Should create a new code jam category.""" subtests = ( [], - [get_mock_category(jams.MAX_CHANNELS, jams.CATEGORY_NAME)], - [get_mock_category(jams.MAX_CHANNELS - 2, "other")], + [get_mock_category(_cog.MAX_CHANNELS, _cog.CATEGORY_NAME)], + [get_mock_category(_cog.MAX_CHANNELS - 2, "other")], ) self.cog.send_status_update = AsyncMock() @@ -109,11 +109,11 @@ class JamCodejamCreateTests(unittest.IsolatedAsyncioTestCase): async def test_category_channel_exist(self): """Should not try to create category channel.""" - expected_category = get_mock_category(jams.MAX_CHANNELS - 2, jams.CATEGORY_NAME) + expected_category = get_mock_category(_cog.MAX_CHANNELS - 2, _cog.CATEGORY_NAME) self.guild.categories = [ - get_mock_category(jams.MAX_CHANNELS - 2, "other"), + get_mock_category(_cog.MAX_CHANNELS - 2, "other"), expected_category, - get_mock_category(0, jams.CATEGORY_NAME), + get_mock_category(0, _cog.CATEGORY_NAME), ] actual_category = await self.cog.get_category(self.guild) @@ -170,5 +170,5 @@ class CodeJamSetup(unittest.TestCase): def test_setup(self): """Should call `bot.add_cog`.""" bot = MockBot() - jams.setup(bot) + _cog.setup(bot) bot.add_cog.assert_called_once() |