diff options
author | 2020-08-14 09:59:56 -0700 | |
---|---|---|
committer | 2020-08-14 09:59:56 -0700 | |
commit | 1c2b384915f4a7ba070c95c86126746bae2f7279 (patch) | |
tree | 576d50314fe1329aaca470d255df0fb1ea3e3a4f | |
parent | Defer imports in extensions using __init__.py (diff) |
Rename "cogs" directory to "exts"
The directory contains modules, which are extensions. It only indirectly
contains cogs through the extensions. Therefore, a technically more
accurate name is "extensions", or "exts" when abbreviated. Furthermore,
"exts" is consistent with SeasonalBot.
-rw-r--r-- | bot/__main__.py | 90 | ||||
-rw-r--r-- | bot/exts/__init__.py (renamed from bot/cogs/__init__.py) | 0 | ||||
-rw-r--r-- | bot/exts/alias.py (renamed from bot/cogs/alias.py) | 2 | ||||
-rw-r--r-- | bot/exts/backend/__init__.py (renamed from bot/cogs/backend/__init__.py) | 0 | ||||
-rw-r--r-- | bot/exts/backend/config_verifier.py (renamed from bot/cogs/backend/config_verifier.py) | 0 | ||||
-rw-r--r-- | bot/exts/backend/error_handler.py (renamed from bot/cogs/backend/error_handler.py) | 0 | ||||
-rw-r--r-- | bot/exts/backend/logging.py (renamed from bot/cogs/backend/logging.py) | 0 | ||||
-rw-r--r-- | bot/exts/backend/sync/__init__.py (renamed from bot/cogs/backend/sync/__init__.py) | 0 | ||||
-rw-r--r-- | bot/exts/backend/sync/_cog.py (renamed from bot/cogs/backend/sync/_cog.py) | 0 | ||||
-rw-r--r-- | bot/exts/backend/sync/_syncers.py (renamed from bot/cogs/backend/sync/_syncers.py) | 0 | ||||
-rw-r--r-- | bot/exts/dm_relay.py (renamed from bot/cogs/dm_relay.py) | 0 | ||||
-rw-r--r-- | bot/exts/duck_pond.py (renamed from bot/cogs/duck_pond.py) | 0 | ||||
-rw-r--r-- | bot/exts/filters/__init__.py (renamed from bot/cogs/filters/__init__.py) | 0 | ||||
-rw-r--r-- | bot/exts/filters/antimalware.py (renamed from bot/cogs/filters/antimalware.py) | 0 | ||||
-rw-r--r-- | bot/exts/filters/antispam.py (renamed from bot/cogs/filters/antispam.py) | 2 | ||||
-rw-r--r-- | bot/exts/filters/filter_lists.py (renamed from bot/cogs/filters/filter_lists.py) | 0 | ||||
-rw-r--r-- | bot/exts/filters/filtering.py (renamed from bot/cogs/filters/filtering.py) | 2 | ||||
-rw-r--r-- | bot/exts/filters/security.py (renamed from bot/cogs/filters/security.py) | 0 | ||||
-rw-r--r-- | bot/exts/filters/token_remover.py (renamed from bot/cogs/filters/token_remover.py) | 2 | ||||
-rw-r--r-- | bot/exts/filters/webhook_remover.py (renamed from bot/cogs/filters/webhook_remover.py) | 2 | ||||
-rw-r--r-- | bot/exts/help_channels.py (renamed from bot/cogs/help_channels.py) | 0 | ||||
-rw-r--r-- | bot/exts/info/__init__.py (renamed from bot/cogs/info/__init__.py) | 0 | ||||
-rw-r--r-- | bot/exts/info/doc.py (renamed from bot/cogs/info/doc.py) | 0 | ||||
-rw-r--r-- | bot/exts/info/help.py (renamed from bot/cogs/info/help.py) | 0 | ||||
-rw-r--r-- | bot/exts/info/information.py (renamed from bot/cogs/info/information.py) | 0 | ||||
-rw-r--r-- | bot/exts/info/python_news.py (renamed from bot/cogs/info/python_news.py) | 0 | ||||
-rw-r--r-- | bot/exts/info/reddit.py (renamed from bot/cogs/info/reddit.py) | 0 | ||||
-rw-r--r-- | bot/exts/info/site.py (renamed from bot/cogs/info/site.py) | 0 | ||||
-rw-r--r-- | bot/exts/info/source.py (renamed from bot/cogs/info/source.py) | 0 | ||||
-rw-r--r-- | bot/exts/info/stats.py (renamed from bot/cogs/info/stats.py) | 0 | ||||
-rw-r--r-- | bot/exts/info/tags.py (renamed from bot/cogs/info/tags.py) | 0 | ||||
-rw-r--r-- | bot/exts/info/wolfram.py (renamed from bot/cogs/info/wolfram.py) | 0 | ||||
-rw-r--r-- | bot/exts/moderation/__init__.py (renamed from bot/cogs/moderation/__init__.py) | 0 | ||||
-rw-r--r-- | bot/exts/moderation/defcon.py (renamed from bot/cogs/moderation/defcon.py) | 2 | ||||
-rw-r--r-- | bot/exts/moderation/incidents.py (renamed from bot/cogs/moderation/incidents.py) | 0 | ||||
-rw-r--r-- | bot/exts/moderation/infraction/__init__.py (renamed from bot/cogs/moderation/infraction/__init__.py) | 0 | ||||
-rw-r--r-- | bot/exts/moderation/infraction/_scheduler.py (renamed from bot/cogs/moderation/infraction/_scheduler.py) | 2 | ||||
-rw-r--r-- | bot/exts/moderation/infraction/_utils.py (renamed from bot/cogs/moderation/infraction/_utils.py) | 0 | ||||
-rw-r--r-- | bot/exts/moderation/infraction/infractions.py (renamed from bot/cogs/moderation/infraction/infractions.py) | 0 | ||||
-rw-r--r-- | bot/exts/moderation/infraction/management.py (renamed from bot/cogs/moderation/infraction/management.py) | 2 | ||||
-rw-r--r-- | bot/exts/moderation/infraction/superstarify.py (renamed from bot/cogs/moderation/infraction/superstarify.py) | 0 | ||||
-rw-r--r-- | bot/exts/moderation/modlog.py (renamed from bot/cogs/moderation/modlog.py) | 0 | ||||
-rw-r--r-- | bot/exts/moderation/silence.py (renamed from bot/cogs/moderation/silence.py) | 0 | ||||
-rw-r--r-- | bot/exts/moderation/slowmode.py (renamed from bot/cogs/moderation/slowmode.py) | 0 | ||||
-rw-r--r-- | bot/exts/moderation/verification.py (renamed from bot/cogs/moderation/verification.py) | 2 | ||||
-rw-r--r-- | bot/exts/moderation/watchchannels/__init__.py (renamed from bot/cogs/moderation/watchchannels/__init__.py) | 0 | ||||
-rw-r--r-- | bot/exts/moderation/watchchannels/_watchchannel.py (renamed from bot/cogs/moderation/watchchannels/_watchchannel.py) | 2 | ||||
-rw-r--r-- | bot/exts/moderation/watchchannels/bigbrother.py (renamed from bot/cogs/moderation/watchchannels/bigbrother.py) | 2 | ||||
-rw-r--r-- | bot/exts/moderation/watchchannels/talentpool.py (renamed from bot/cogs/moderation/watchchannels/talentpool.py) | 0 | ||||
-rw-r--r-- | bot/exts/off_topic_names.py (renamed from bot/cogs/off_topic_names.py) | 0 | ||||
-rw-r--r-- | bot/exts/utils/__init__.py (renamed from bot/cogs/utils/__init__.py) | 0 | ||||
-rw-r--r-- | bot/exts/utils/bot.py (renamed from bot/cogs/utils/bot.py) | 2 | ||||
-rw-r--r-- | bot/exts/utils/clean.py (renamed from bot/cogs/utils/clean.py) | 2 | ||||
-rw-r--r-- | bot/exts/utils/eval.py (renamed from bot/cogs/utils/eval.py) | 0 | ||||
-rw-r--r-- | bot/exts/utils/extensions.py (renamed from bot/cogs/utils/extensions.py) | 16 | ||||
-rw-r--r-- | bot/exts/utils/jams.py (renamed from bot/cogs/utils/jams.py) | 0 | ||||
-rw-r--r-- | bot/exts/utils/reminders.py (renamed from bot/cogs/utils/reminders.py) | 0 | ||||
-rw-r--r-- | bot/exts/utils/snekbox.py (renamed from bot/cogs/utils/snekbox.py) | 0 | ||||
-rw-r--r-- | bot/exts/utils/utils.py (renamed from bot/cogs/utils/utils.py) | 0 | ||||
-rw-r--r-- | tests/bot/exts/__init__.py (renamed from tests/bot/cogs/__init__.py) | 0 | ||||
-rw-r--r-- | tests/bot/exts/backend/__init__.py (renamed from tests/bot/cogs/backend/__init__.py) | 0 | ||||
-rw-r--r-- | tests/bot/exts/backend/sync/__init__.py (renamed from tests/bot/cogs/backend/sync/__init__.py) | 0 | ||||
-rw-r--r-- | tests/bot/exts/backend/sync/test_base.py (renamed from tests/bot/cogs/backend/sync/test_base.py) | 2 | ||||
-rw-r--r-- | tests/bot/exts/backend/sync/test_cog.py (renamed from tests/bot/cogs/backend/sync/test_cog.py) | 12 | ||||
-rw-r--r-- | tests/bot/exts/backend/sync/test_roles.py (renamed from tests/bot/cogs/backend/sync/test_roles.py) | 2 | ||||
-rw-r--r-- | tests/bot/exts/backend/sync/test_users.py (renamed from tests/bot/cogs/backend/sync/test_users.py) | 2 | ||||
-rw-r--r-- | tests/bot/exts/backend/test_logging.py (renamed from tests/bot/cogs/backend/test_logging.py) | 6 | ||||
-rw-r--r-- | tests/bot/exts/filters/__init__.py (renamed from tests/bot/cogs/filters/__init__.py) | 0 | ||||
-rw-r--r-- | tests/bot/exts/filters/test_antimalware.py (renamed from tests/bot/cogs/filters/test_antimalware.py) | 2 | ||||
-rw-r--r-- | tests/bot/exts/filters/test_antispam.py (renamed from tests/bot/cogs/filters/test_antispam.py) | 2 | ||||
-rw-r--r-- | tests/bot/exts/filters/test_security.py (renamed from tests/bot/cogs/filters/test_security.py) | 2 | ||||
-rw-r--r-- | tests/bot/exts/filters/test_token_remover.py (renamed from tests/bot/cogs/filters/test_token_remover.py) | 22 | ||||
-rw-r--r-- | tests/bot/exts/info/__init__.py (renamed from tests/bot/cogs/info/__init__.py) | 0 | ||||
-rw-r--r-- | tests/bot/exts/info/test_information.py (renamed from tests/bot/cogs/info/test_information.py) | 20 | ||||
-rw-r--r-- | tests/bot/exts/moderation/__init__.py (renamed from tests/bot/cogs/moderation/__init__.py) | 0 | ||||
-rw-r--r-- | tests/bot/exts/moderation/infraction/__init__.py (renamed from tests/bot/cogs/moderation/infraction/__init__.py) | 0 | ||||
-rw-r--r-- | tests/bot/exts/moderation/infraction/test_infractions.py (renamed from tests/bot/cogs/moderation/infraction/test_infractions.py) | 8 | ||||
-rw-r--r-- | tests/bot/exts/moderation/test_incidents.py (renamed from tests/bot/cogs/moderation/test_incidents.py) | 64 | ||||
-rw-r--r-- | tests/bot/exts/moderation/test_modlog.py (renamed from tests/bot/cogs/moderation/test_modlog.py) | 2 | ||||
-rw-r--r-- | tests/bot/exts/moderation/test_silence.py (renamed from tests/bot/cogs/moderation/test_silence.py) | 12 | ||||
-rw-r--r-- | tests/bot/exts/moderation/test_slowmode.py (renamed from tests/bot/cogs/moderation/test_slowmode.py) | 6 | ||||
-rw-r--r-- | tests/bot/exts/test_cogs.py (renamed from tests/bot/cogs/test_cogs.py) | 7 | ||||
-rw-r--r-- | tests/bot/exts/test_duck_pond.py (renamed from tests/bot/cogs/test_duck_pond.py) | 10 | ||||
-rw-r--r-- | tests/bot/exts/utils/__init__.py (renamed from tests/bot/cogs/utils/__init__.py) | 0 | ||||
-rw-r--r-- | tests/bot/exts/utils/test_jams.py (renamed from tests/bot/cogs/utils/test_jams.py) | 2 | ||||
-rw-r--r-- | tests/bot/exts/utils/test_snekbox.py (renamed from tests/bot/cogs/utils/test_snekbox.py) | 12 |
86 files changed, 164 insertions, 163 deletions
diff --git a/bot/__main__.py b/bot/__main__.py index 4b0f6dfe4..555847357 100644 --- a/bot/__main__.py +++ b/bot/__main__.py @@ -34,67 +34,67 @@ bot = Bot( ) # Backend -bot.load_extension("bot.cogs.backend.config_verifier") -bot.load_extension("bot.cogs.backend.error_handler") -bot.load_extension("bot.cogs.backend.logging") -bot.load_extension("bot.cogs.backend.sync") +bot.load_extension("bot.exts.backend.config_verifier") +bot.load_extension("bot.exts.backend.error_handler") +bot.load_extension("bot.exts.backend.logging") +bot.load_extension("bot.exts.backend.sync") # Filters -bot.load_extension("bot.cogs.filters.antimalware") -bot.load_extension("bot.cogs.filters.antispam") -bot.load_extension("bot.cogs.filters.filter_lists") -bot.load_extension("bot.cogs.filters.filtering") -bot.load_extension("bot.cogs.filters.security") -bot.load_extension("bot.cogs.filters.token_remover") -bot.load_extension("bot.cogs.filters.webhook_remover") +bot.load_extension("bot.exts.filters.antimalware") +bot.load_extension("bot.exts.filters.antispam") +bot.load_extension("bot.exts.filters.filter_lists") +bot.load_extension("bot.exts.filters.filtering") +bot.load_extension("bot.exts.filters.security") +bot.load_extension("bot.exts.filters.token_remover") +bot.load_extension("bot.exts.filters.webhook_remover") # Info -bot.load_extension("bot.cogs.info.doc") -bot.load_extension("bot.cogs.info.help") -bot.load_extension("bot.cogs.info.information") -bot.load_extension("bot.cogs.info.python_news") -bot.load_extension("bot.cogs.info.reddit") -bot.load_extension("bot.cogs.info.site") -bot.load_extension("bot.cogs.info.source") -bot.load_extension("bot.cogs.info.stats") -bot.load_extension("bot.cogs.info.tags") -bot.load_extension("bot.cogs.info.wolfram") +bot.load_extension("bot.exts.info.doc") +bot.load_extension("bot.exts.info.help") +bot.load_extension("bot.exts.info.information") +bot.load_extension("bot.exts.info.python_news") +bot.load_extension("bot.exts.info.reddit") +bot.load_extension("bot.exts.info.site") +bot.load_extension("bot.exts.info.source") +bot.load_extension("bot.exts.info.stats") +bot.load_extension("bot.exts.info.tags") +bot.load_extension("bot.exts.info.wolfram") # Moderation -bot.load_extension("bot.cogs.moderation.defcon") -bot.load_extension("bot.cogs.moderation.incidents") -bot.load_extension("bot.cogs.moderation.modlog") -bot.load_extension("bot.cogs.moderation.silence") -bot.load_extension("bot.cogs.moderation.slowmode") -bot.load_extension("bot.cogs.moderation.verification") +bot.load_extension("bot.exts.moderation.defcon") +bot.load_extension("bot.exts.moderation.incidents") +bot.load_extension("bot.exts.moderation.modlog") +bot.load_extension("bot.exts.moderation.silence") +bot.load_extension("bot.exts.moderation.slowmode") +bot.load_extension("bot.exts.moderation.verification") # Moderation - Infraction -bot.load_extension("bot.cogs.moderation.infraction.infractions") -bot.load_extension("bot.cogs.moderation.infraction.management") -bot.load_extension("bot.cogs.moderation.infraction.superstarify") +bot.load_extension("bot.exts.moderation.infraction.infractions") +bot.load_extension("bot.exts.moderation.infraction.management") +bot.load_extension("bot.exts.moderation.infraction.superstarify") # Moderation - Watchchannels -bot.load_extension("bot.cogs.moderation.watchchannels.bigbrother") -bot.load_extension("bot.cogs.moderation.watchchannels.talentpool") +bot.load_extension("bot.exts.moderation.watchchannels.bigbrother") +bot.load_extension("bot.exts.moderation.watchchannels.talentpool") # Utils -bot.load_extension("bot.cogs.utils.bot") -bot.load_extension("bot.cogs.utils.clean") -bot.load_extension("bot.cogs.utils.eval") -bot.load_extension("bot.cogs.utils.extensions") -bot.load_extension("bot.cogs.utils.jams") -bot.load_extension("bot.cogs.utils.reminders") -bot.load_extension("bot.cogs.utils.snekbox") -bot.load_extension("bot.cogs.utils.utils") +bot.load_extension("bot.exts.utils.bot") +bot.load_extension("bot.exts.utils.clean") +bot.load_extension("bot.exts.utils.eval") +bot.load_extension("bot.exts.utils.extensions") +bot.load_extension("bot.exts.utils.jams") +bot.load_extension("bot.exts.utils.reminders") +bot.load_extension("bot.exts.utils.snekbox") +bot.load_extension("bot.exts.utils.utils") # Misc -bot.load_extension("bot.cogs.alias") -bot.load_extension("bot.cogs.dm_relay") -bot.load_extension("bot.cogs.duck_pond") -bot.load_extension("bot.cogs.off_topic_names") +bot.load_extension("bot.exts.alias") +bot.load_extension("bot.exts.dm_relay") +bot.load_extension("bot.exts.duck_pond") +bot.load_extension("bot.exts.off_topic_names") if constants.HelpChannels.enable: - bot.load_extension("bot.cogs.help_channels") + bot.load_extension("bot.exts.help_channels") # Apply `message_edited_at` patch if discord.py did not yet release a bug fix. if not hasattr(discord.message.Message, '_handle_edited_timestamp'): diff --git a/bot/cogs/__init__.py b/bot/exts/__init__.py index e69de29bb..e69de29bb 100644 --- a/bot/cogs/__init__.py +++ b/bot/exts/__init__.py diff --git a/bot/cogs/alias.py b/bot/exts/alias.py index 3c5a35c24..77867b933 100644 --- a/bot/cogs/alias.py +++ b/bot/exts/alias.py @@ -8,8 +8,8 @@ from discord.ext.commands import ( ) from bot.bot import Bot -from bot.cogs.utils.extensions import Extension from bot.converters import FetchedMember, TagNameConverter +from bot.exts.utils.extensions import Extension from bot.pagination import LinePaginator log = logging.getLogger(__name__) diff --git a/bot/cogs/backend/__init__.py b/bot/exts/backend/__init__.py index e69de29bb..e69de29bb 100644 --- a/bot/cogs/backend/__init__.py +++ b/bot/exts/backend/__init__.py diff --git a/bot/cogs/backend/config_verifier.py b/bot/exts/backend/config_verifier.py index d72c6c22e..d72c6c22e 100644 --- a/bot/cogs/backend/config_verifier.py +++ b/bot/exts/backend/config_verifier.py diff --git a/bot/cogs/backend/error_handler.py b/bot/exts/backend/error_handler.py index f9d4de638..f9d4de638 100644 --- a/bot/cogs/backend/error_handler.py +++ b/bot/exts/backend/error_handler.py diff --git a/bot/cogs/backend/logging.py b/bot/exts/backend/logging.py index 94fa2b139..94fa2b139 100644 --- a/bot/cogs/backend/logging.py +++ b/bot/exts/backend/logging.py diff --git a/bot/cogs/backend/sync/__init__.py b/bot/exts/backend/sync/__init__.py index 2541beaa8..2541beaa8 100644 --- a/bot/cogs/backend/sync/__init__.py +++ b/bot/exts/backend/sync/__init__.py diff --git a/bot/cogs/backend/sync/_cog.py b/bot/exts/backend/sync/_cog.py index b6068f328..b6068f328 100644 --- a/bot/cogs/backend/sync/_cog.py +++ b/bot/exts/backend/sync/_cog.py diff --git a/bot/cogs/backend/sync/_syncers.py b/bot/exts/backend/sync/_syncers.py index f7ba811bc..f7ba811bc 100644 --- a/bot/cogs/backend/sync/_syncers.py +++ b/bot/exts/backend/sync/_syncers.py diff --git a/bot/cogs/dm_relay.py b/bot/exts/dm_relay.py index 0d8f340b4..0d8f340b4 100644 --- a/bot/cogs/dm_relay.py +++ b/bot/exts/dm_relay.py diff --git a/bot/cogs/duck_pond.py b/bot/exts/duck_pond.py index 7021069fa..7021069fa 100644 --- a/bot/cogs/duck_pond.py +++ b/bot/exts/duck_pond.py diff --git a/bot/cogs/filters/__init__.py b/bot/exts/filters/__init__.py index e69de29bb..e69de29bb 100644 --- a/bot/cogs/filters/__init__.py +++ b/bot/exts/filters/__init__.py diff --git a/bot/cogs/filters/antimalware.py b/bot/exts/filters/antimalware.py index c76bd2c60..c76bd2c60 100644 --- a/bot/cogs/filters/antimalware.py +++ b/bot/exts/filters/antimalware.py diff --git a/bot/cogs/filters/antispam.py b/bot/exts/filters/antispam.py index d2dccea06..3c5f13ebf 100644 --- a/bot/cogs/filters/antispam.py +++ b/bot/exts/filters/antispam.py @@ -11,7 +11,6 @@ from discord.ext.commands import Cog from bot import rules from bot.bot import Bot -from bot.cogs.moderation.modlog import ModLog from bot.constants import ( AntiSpam as AntiSpamConfig, Channels, Colours, DEBUG_MODE, Event, Filter, @@ -19,6 +18,7 @@ from bot.constants import ( STAFF_ROLES, ) from bot.converters import Duration +from bot.exts.moderation.modlog import ModLog from bot.utils.messages import send_attachments diff --git a/bot/cogs/filters/filter_lists.py b/bot/exts/filters/filter_lists.py index c15adc461..c15adc461 100644 --- a/bot/cogs/filters/filter_lists.py +++ b/bot/exts/filters/filter_lists.py diff --git a/bot/cogs/filters/filtering.py b/bot/exts/filters/filtering.py index 556b466ef..2ae476d8a 100644 --- a/bot/cogs/filters/filtering.py +++ b/bot/exts/filters/filtering.py @@ -12,11 +12,11 @@ from discord.ext.commands import Cog from discord.utils import escape_markdown from bot.bot import Bot -from bot.cogs.moderation.modlog import ModLog from bot.constants import ( Channels, Colours, Filter, Icons, URLs ) +from bot.exts.moderation.modlog import ModLog from bot.utils.redis_cache import RedisCache from bot.utils.regex import INVITE_RE from bot.utils.scheduling import Scheduler diff --git a/bot/cogs/filters/security.py b/bot/exts/filters/security.py index c680c5e27..c680c5e27 100644 --- a/bot/cogs/filters/security.py +++ b/bot/exts/filters/security.py diff --git a/bot/cogs/filters/token_remover.py b/bot/exts/filters/token_remover.py index 8eace07b6..0eda3dc6a 100644 --- a/bot/cogs/filters/token_remover.py +++ b/bot/exts/filters/token_remover.py @@ -9,8 +9,8 @@ from discord.ext.commands import Cog from bot import utils from bot.bot import Bot -from bot.cogs.moderation.modlog import ModLog from bot.constants import Channels, Colours, Event, Icons +from bot.exts.moderation.modlog import ModLog log = logging.getLogger(__name__) diff --git a/bot/cogs/filters/webhook_remover.py b/bot/exts/filters/webhook_remover.py index 5812da87c..ca126ebf5 100644 --- a/bot/cogs/filters/webhook_remover.py +++ b/bot/exts/filters/webhook_remover.py @@ -5,8 +5,8 @@ from discord import Colour, Message, NotFound from discord.ext.commands import Cog from bot.bot import Bot -from bot.cogs.moderation.modlog import ModLog from bot.constants import Channels, Colours, Event, Icons +from bot.exts.moderation.modlog import ModLog WEBHOOK_URL_RE = re.compile(r"((?:https?://)?discord(?:app)?\.com/api/webhooks/\d+/)\S+/?", re.IGNORECASE) diff --git a/bot/cogs/help_channels.py b/bot/exts/help_channels.py index 57094751e..57094751e 100644 --- a/bot/cogs/help_channels.py +++ b/bot/exts/help_channels.py diff --git a/bot/cogs/info/__init__.py b/bot/exts/info/__init__.py index e69de29bb..e69de29bb 100644 --- a/bot/cogs/info/__init__.py +++ b/bot/exts/info/__init__.py diff --git a/bot/cogs/info/doc.py b/bot/exts/info/doc.py index 204cffb37..204cffb37 100644 --- a/bot/cogs/info/doc.py +++ b/bot/exts/info/doc.py diff --git a/bot/cogs/info/help.py b/bot/exts/info/help.py index 3d1d6fd10..3d1d6fd10 100644 --- a/bot/cogs/info/help.py +++ b/bot/exts/info/help.py diff --git a/bot/cogs/info/information.py b/bot/exts/info/information.py index 8982196d1..8982196d1 100644 --- a/bot/cogs/info/information.py +++ b/bot/exts/info/information.py diff --git a/bot/cogs/info/python_news.py b/bot/exts/info/python_news.py index 0ab5738a4..0ab5738a4 100644 --- a/bot/cogs/info/python_news.py +++ b/bot/exts/info/python_news.py diff --git a/bot/cogs/info/reddit.py b/bot/exts/info/reddit.py index d853ab2ea..d853ab2ea 100644 --- a/bot/cogs/info/reddit.py +++ b/bot/exts/info/reddit.py diff --git a/bot/cogs/info/site.py b/bot/exts/info/site.py index ac29daa1d..ac29daa1d 100644 --- a/bot/cogs/info/site.py +++ b/bot/exts/info/site.py diff --git a/bot/cogs/info/source.py b/bot/exts/info/source.py index 205e0ba81..205e0ba81 100644 --- a/bot/cogs/info/source.py +++ b/bot/exts/info/source.py diff --git a/bot/cogs/info/stats.py b/bot/exts/info/stats.py index d42f55466..d42f55466 100644 --- a/bot/cogs/info/stats.py +++ b/bot/exts/info/stats.py diff --git a/bot/cogs/info/tags.py b/bot/exts/info/tags.py index 3d76c5c08..3d76c5c08 100644 --- a/bot/cogs/info/tags.py +++ b/bot/exts/info/tags.py diff --git a/bot/cogs/info/wolfram.py b/bot/exts/info/wolfram.py index e6cae3bb8..e6cae3bb8 100644 --- a/bot/cogs/info/wolfram.py +++ b/bot/exts/info/wolfram.py diff --git a/bot/cogs/moderation/__init__.py b/bot/exts/moderation/__init__.py index e69de29bb..e69de29bb 100644 --- a/bot/cogs/moderation/__init__.py +++ b/bot/exts/moderation/__init__.py diff --git a/bot/cogs/moderation/defcon.py b/bot/exts/moderation/defcon.py index e78435a7d..b75a4dcfe 100644 --- a/bot/cogs/moderation/defcon.py +++ b/bot/exts/moderation/defcon.py @@ -9,9 +9,9 @@ from discord import Colour, Embed, Member from discord.ext.commands import Cog, Context, group from bot.bot import Bot -from bot.cogs.moderation.modlog import ModLog from bot.constants import Channels, Colours, Emojis, Event, Icons, Roles from bot.decorators import with_role +from bot.exts.moderation.modlog import ModLog log = logging.getLogger(__name__) diff --git a/bot/cogs/moderation/incidents.py b/bot/exts/moderation/incidents.py index e49913552..e49913552 100644 --- a/bot/cogs/moderation/incidents.py +++ b/bot/exts/moderation/incidents.py diff --git a/bot/cogs/moderation/infraction/__init__.py b/bot/exts/moderation/infraction/__init__.py index e69de29bb..e69de29bb 100644 --- a/bot/cogs/moderation/infraction/__init__.py +++ b/bot/exts/moderation/infraction/__init__.py diff --git a/bot/cogs/moderation/infraction/_scheduler.py b/bot/exts/moderation/infraction/_scheduler.py index 33944a8db..1310fd3d9 100644 --- a/bot/cogs/moderation/infraction/_scheduler.py +++ b/bot/exts/moderation/infraction/_scheduler.py @@ -12,8 +12,8 @@ from discord.ext.commands import Context from bot import constants from bot.api import ResponseCodeError from bot.bot import Bot -from bot.cogs.moderation.modlog import ModLog from bot.constants import Colours, STAFF_CHANNELS +from bot.exts.moderation.modlog import ModLog from bot.utils import time from bot.utils.scheduling import Scheduler from . import _utils diff --git a/bot/cogs/moderation/infraction/_utils.py b/bot/exts/moderation/infraction/_utils.py index fb55287b6..fb55287b6 100644 --- a/bot/cogs/moderation/infraction/_utils.py +++ b/bot/exts/moderation/infraction/_utils.py diff --git a/bot/cogs/moderation/infraction/infractions.py b/bot/exts/moderation/infraction/infractions.py index cb459b447..cb459b447 100644 --- a/bot/cogs/moderation/infraction/infractions.py +++ b/bot/exts/moderation/infraction/infractions.py diff --git a/bot/cogs/moderation/infraction/management.py b/bot/exts/moderation/infraction/management.py index 9e7ae8113..eea6ac9ea 100644 --- a/bot/cogs/moderation/infraction/management.py +++ b/bot/exts/moderation/infraction/management.py @@ -9,8 +9,8 @@ from discord.ext.commands import Context from bot import constants from bot.bot import Bot -from bot.cogs.moderation.modlog import ModLog from bot.converters import Expiry, InfractionSearchQuery, allowed_strings, proxy_user +from bot.exts.moderation.modlog import ModLog from bot.pagination import LinePaginator from bot.utils import time from bot.utils.checks import in_whitelist_check, with_role_check diff --git a/bot/cogs/moderation/infraction/superstarify.py b/bot/exts/moderation/infraction/superstarify.py index 7dc5b4691..7dc5b4691 100644 --- a/bot/cogs/moderation/infraction/superstarify.py +++ b/bot/exts/moderation/infraction/superstarify.py diff --git a/bot/cogs/moderation/modlog.py b/bot/exts/moderation/modlog.py index c86f04b9d..c86f04b9d 100644 --- a/bot/cogs/moderation/modlog.py +++ b/bot/exts/moderation/modlog.py diff --git a/bot/cogs/moderation/silence.py b/bot/exts/moderation/silence.py index 4af87c724..4af87c724 100644 --- a/bot/cogs/moderation/silence.py +++ b/bot/exts/moderation/silence.py diff --git a/bot/cogs/moderation/slowmode.py b/bot/exts/moderation/slowmode.py index 1d055afac..1d055afac 100644 --- a/bot/cogs/moderation/slowmode.py +++ b/bot/exts/moderation/slowmode.py diff --git a/bot/cogs/moderation/verification.py b/bot/exts/moderation/verification.py index ba95ab5e4..0db3e800d 100644 --- a/bot/cogs/moderation/verification.py +++ b/bot/exts/moderation/verification.py @@ -6,8 +6,8 @@ from discord.ext.commands import Cog, Context, command from bot import constants from bot.bot import Bot -from bot.cogs.moderation.modlog import ModLog from bot.decorators import in_whitelist, without_role +from bot.exts.moderation.modlog import ModLog from bot.utils.checks import InWhitelistCheckFailure, without_role_check log = logging.getLogger(__name__) diff --git a/bot/cogs/moderation/watchchannels/__init__.py b/bot/exts/moderation/watchchannels/__init__.py index e69de29bb..e69de29bb 100644 --- a/bot/cogs/moderation/watchchannels/__init__.py +++ b/bot/exts/moderation/watchchannels/__init__.py diff --git a/bot/cogs/moderation/watchchannels/_watchchannel.py b/bot/exts/moderation/watchchannels/_watchchannel.py index 488ae704d..013d3ee03 100644 --- a/bot/cogs/moderation/watchchannels/_watchchannel.py +++ b/bot/exts/moderation/watchchannels/_watchchannel.py @@ -14,8 +14,8 @@ from discord.ext.commands import Cog, Context from bot.api import ResponseCodeError from bot.bot import Bot -from bot.cogs.moderation.modlog import ModLog from bot.constants import BigBrother as BigBrotherConfig, Guild as GuildConfig, Icons +from bot.exts.moderation.modlog import ModLog from bot.pagination import LinePaginator from bot.utils import CogABCMeta, messages from bot.utils.time import time_since diff --git a/bot/cogs/moderation/watchchannels/bigbrother.py b/bot/exts/moderation/watchchannels/bigbrother.py index 7db34bcf2..4ac916c9e 100644 --- a/bot/cogs/moderation/watchchannels/bigbrother.py +++ b/bot/exts/moderation/watchchannels/bigbrother.py @@ -5,10 +5,10 @@ from collections import ChainMap from discord.ext.commands import Cog, Context, group from bot.bot import Bot -from bot.cogs.moderation.infraction._utils import post_infraction from bot.constants import Channels, MODERATION_ROLES, Webhooks from bot.converters import FetchedMember from bot.decorators import with_role +from bot.exts.moderation.infraction._utils import post_infraction from ._watchchannel import WatchChannel log = logging.getLogger(__name__) diff --git a/bot/cogs/moderation/watchchannels/talentpool.py b/bot/exts/moderation/watchchannels/talentpool.py index 2972f56e1..2972f56e1 100644 --- a/bot/cogs/moderation/watchchannels/talentpool.py +++ b/bot/exts/moderation/watchchannels/talentpool.py diff --git a/bot/cogs/off_topic_names.py b/bot/exts/off_topic_names.py index ce95450e0..ce95450e0 100644 --- a/bot/cogs/off_topic_names.py +++ b/bot/exts/off_topic_names.py diff --git a/bot/cogs/utils/__init__.py b/bot/exts/utils/__init__.py index e69de29bb..e69de29bb 100644 --- a/bot/cogs/utils/__init__.py +++ b/bot/exts/utils/__init__.py diff --git a/bot/cogs/utils/bot.py b/bot/exts/utils/bot.py index 71ed54f60..866fd2b68 100644 --- a/bot/cogs/utils/bot.py +++ b/bot/exts/utils/bot.py @@ -8,9 +8,9 @@ from discord import Embed, Message, RawMessageUpdateEvent, TextChannel from discord.ext.commands import Cog, Context, command, group from bot.bot import Bot -from bot.cogs.filters.token_remover import TokenRemover from bot.constants import Categories, Channels, DEBUG_MODE, Guild, MODERATION_ROLES, Roles, URLs from bot.decorators import with_role +from bot.exts.filters.token_remover import TokenRemover from bot.utils.messages import wait_for_deletion log = logging.getLogger(__name__) diff --git a/bot/cogs/utils/clean.py b/bot/exts/utils/clean.py index c156ff02e..d9a7aafe1 100644 --- a/bot/cogs/utils/clean.py +++ b/bot/exts/utils/clean.py @@ -8,11 +8,11 @@ from discord.ext import commands from discord.ext.commands import Cog, Context, group from bot.bot import Bot -from bot.cogs.moderation.modlog import ModLog from bot.constants import ( Channels, CleanMessages, Colours, Event, Icons, MODERATION_ROLES, NEGATIVE_REPLIES ) from bot.decorators import with_role +from bot.exts.moderation.modlog import ModLog log = logging.getLogger(__name__) diff --git a/bot/cogs/utils/eval.py b/bot/exts/utils/eval.py index eb8bfb1cf..eb8bfb1cf 100644 --- a/bot/cogs/utils/eval.py +++ b/bot/exts/utils/eval.py diff --git a/bot/cogs/utils/extensions.py b/bot/exts/utils/extensions.py index 2cde07035..671397650 100644 --- a/bot/cogs/utils/extensions.py +++ b/bot/exts/utils/extensions.py @@ -10,7 +10,7 @@ from discord import Colour, Embed from discord.ext import commands from discord.ext.commands import Context, group -from bot import cogs +from bot import exts from bot.bot import Bot from bot.constants import Emojis, MODERATION_ROLES, Roles, URLs from bot.pagination import LinePaginator @@ -20,12 +20,12 @@ log = logging.getLogger(__name__) def walk_extensions() -> t.Iterator[str]: - """Yield extension names from the bot.cogs subpackage.""" + """Yield extension names from the bot.exts subpackage.""" def on_error(name: str) -> t.NoReturn: raise ImportError(name=name) # pragma: no cover - for module in pkgutil.walk_packages(cogs.__path__, f"{cogs.__name__}.", onerror=on_error): + for module in pkgutil.walk_packages(exts.__path__, f"{exts.__name__}.", onerror=on_error): if module.name.rsplit(".", maxsplit=1)[-1].startswith("_"): # Ignore module/package names starting with an underscore. continue @@ -39,9 +39,9 @@ def walk_extensions() -> t.Iterator[str]: yield module.name -UNLOAD_BLACKLIST = {f"{cogs.__name__}.utils.extensions", f"{cogs.__name__}.moderation.modlog"} +UNLOAD_BLACKLIST = {f"{exts.__name__}.utils.extensions", f"{exts.__name__}.moderation.modlog"} EXTENSIONS = frozenset(walk_extensions()) -COG_PATH_LEN = len(cogs.__name__.split(".")) +BASE_PATH_LEN = len(exts.__name__.split(".")) class Action(Enum): @@ -70,7 +70,7 @@ class Extension(commands.Converter): if argument in EXTENSIONS: return argument - elif (qualified_arg := f"{cogs.__name__}.{argument}") in EXTENSIONS: + elif (qualified_arg := f"{exts.__name__}.{argument}") in EXTENSIONS: return qualified_arg matches = [] @@ -205,8 +205,8 @@ class Extensions(commands.Cog): status = Emojis.status_offline path = ext.split(".") - if len(path) > COG_PATH_LEN + 1: - category = " - ".join(path[COG_PATH_LEN:-1]) + if len(path) > BASE_PATH_LEN + 1: + category = " - ".join(path[BASE_PATH_LEN:-1]) else: category = "uncategorised" diff --git a/bot/cogs/utils/jams.py b/bot/exts/utils/jams.py index b3102db2f..b3102db2f 100644 --- a/bot/cogs/utils/jams.py +++ b/bot/exts/utils/jams.py diff --git a/bot/cogs/utils/reminders.py b/bot/exts/utils/reminders.py index 670493bcf..670493bcf 100644 --- a/bot/cogs/utils/reminders.py +++ b/bot/exts/utils/reminders.py diff --git a/bot/cogs/utils/snekbox.py b/bot/exts/utils/snekbox.py index 52c8b6f88..52c8b6f88 100644 --- a/bot/cogs/utils/snekbox.py +++ b/bot/exts/utils/snekbox.py diff --git a/bot/cogs/utils/utils.py b/bot/exts/utils/utils.py index d96abbd5a..d96abbd5a 100644 --- a/bot/cogs/utils/utils.py +++ b/bot/exts/utils/utils.py diff --git a/tests/bot/cogs/__init__.py b/tests/bot/exts/__init__.py index e69de29bb..e69de29bb 100644 --- a/tests/bot/cogs/__init__.py +++ b/tests/bot/exts/__init__.py diff --git a/tests/bot/cogs/backend/__init__.py b/tests/bot/exts/backend/__init__.py index e69de29bb..e69de29bb 100644 --- a/tests/bot/cogs/backend/__init__.py +++ b/tests/bot/exts/backend/__init__.py diff --git a/tests/bot/cogs/backend/sync/__init__.py b/tests/bot/exts/backend/sync/__init__.py index e69de29bb..e69de29bb 100644 --- a/tests/bot/cogs/backend/sync/__init__.py +++ b/tests/bot/exts/backend/sync/__init__.py diff --git a/tests/bot/cogs/backend/sync/test_base.py b/tests/bot/exts/backend/sync/test_base.py index 3009aacb6..886c243cf 100644 --- a/tests/bot/cogs/backend/sync/test_base.py +++ b/tests/bot/exts/backend/sync/test_base.py @@ -6,7 +6,7 @@ import discord from bot import constants from bot.api import ResponseCodeError -from bot.cogs.backend.sync._syncers import Syncer, _Diff +from bot.exts.backend.sync._syncers import Syncer, _Diff from tests import helpers diff --git a/tests/bot/cogs/backend/sync/test_cog.py b/tests/bot/exts/backend/sync/test_cog.py index e40552817..1b89564f2 100644 --- a/tests/bot/cogs/backend/sync/test_cog.py +++ b/tests/bot/exts/backend/sync/test_cog.py @@ -5,9 +5,9 @@ import discord from bot import constants from bot.api import ResponseCodeError -from bot.cogs.backend import sync -from bot.cogs.backend.sync._cog import Sync -from bot.cogs.backend.sync._syncers import Syncer +from bot.exts.backend import sync +from bot.exts.backend.sync._cog import Sync +from bot.exts.backend.sync._syncers import Syncer from tests import helpers from tests.base import CommandTestCase @@ -30,12 +30,12 @@ class SyncCogTestCase(unittest.IsolatedAsyncioTestCase): self.bot = helpers.MockBot() self.role_syncer_patcher = mock.patch( - "bot.cogs.backend.sync._syncers.RoleSyncer", + "bot.exts.backend.sync._syncers.RoleSyncer", autospec=Syncer, spec_set=True ) self.user_syncer_patcher = mock.patch( - "bot.cogs.backend.sync._syncers.UserSyncer", + "bot.exts.backend.sync._syncers.UserSyncer", autospec=Syncer, spec_set=True ) @@ -132,7 +132,7 @@ class SyncCogListenerTests(SyncCogTestCase): super().setUp() self.cog.patch_user = mock.AsyncMock(spec_set=self.cog.patch_user) - self.guild_id_patcher = mock.patch("bot.cogs.backend.sync._cog.constants.Guild.id", 5) + self.guild_id_patcher = mock.patch("bot.exts.backend.sync._cog.constants.Guild.id", 5) self.guild_id = self.guild_id_patcher.start() self.guild = helpers.MockGuild(id=self.guild_id) diff --git a/tests/bot/cogs/backend/sync/test_roles.py b/tests/bot/exts/backend/sync/test_roles.py index 99d682ede..7b9f40cad 100644 --- a/tests/bot/cogs/backend/sync/test_roles.py +++ b/tests/bot/exts/backend/sync/test_roles.py @@ -3,7 +3,7 @@ from unittest import mock import discord -from bot.cogs.backend.sync._syncers import RoleSyncer, _Diff, _Role +from bot.exts.backend.sync._syncers import RoleSyncer, _Diff, _Role from tests import helpers diff --git a/tests/bot/cogs/backend/sync/test_users.py b/tests/bot/exts/backend/sync/test_users.py index 51dcbe48a..c0a1da35c 100644 --- a/tests/bot/cogs/backend/sync/test_users.py +++ b/tests/bot/exts/backend/sync/test_users.py @@ -1,7 +1,7 @@ import unittest from unittest import mock -from bot.cogs.backend.sync._syncers import UserSyncer, _Diff, _User +from bot.exts.backend.sync._syncers import UserSyncer, _Diff, _User from tests import helpers diff --git a/tests/bot/cogs/backend/test_logging.py b/tests/bot/exts/backend/test_logging.py index c867773e2..466f207d9 100644 --- a/tests/bot/cogs/backend/test_logging.py +++ b/tests/bot/exts/backend/test_logging.py @@ -2,7 +2,7 @@ import unittest from unittest.mock import patch from bot import constants -from bot.cogs.backend.logging import Logging +from bot.exts.backend.logging import Logging from tests.helpers import MockBot, MockTextChannel @@ -14,7 +14,7 @@ class LoggingTests(unittest.IsolatedAsyncioTestCase): self.cog = Logging(self.bot) self.dev_log = MockTextChannel(id=1234, name="dev-log") - @patch("bot.cogs.backend.logging.DEBUG_MODE", False) + @patch("bot.exts.backend.logging.DEBUG_MODE", False) async def test_debug_mode_false(self): """Should send connected message to dev-log.""" self.bot.get_channel.return_value = self.dev_log @@ -24,7 +24,7 @@ class LoggingTests(unittest.IsolatedAsyncioTestCase): self.bot.get_channel.assert_called_once_with(constants.Channels.dev_log) self.dev_log.send.assert_awaited_once() - @patch("bot.cogs.backend.logging.DEBUG_MODE", True) + @patch("bot.exts.backend.logging.DEBUG_MODE", True) async def test_debug_mode_true(self): """Should not send anything to dev-log.""" await self.cog.startup_greeting() diff --git a/tests/bot/cogs/filters/__init__.py b/tests/bot/exts/filters/__init__.py index e69de29bb..e69de29bb 100644 --- a/tests/bot/cogs/filters/__init__.py +++ b/tests/bot/exts/filters/__init__.py diff --git a/tests/bot/cogs/filters/test_antimalware.py b/tests/bot/exts/filters/test_antimalware.py index b00211f47..960894e5c 100644 --- a/tests/bot/cogs/filters/test_antimalware.py +++ b/tests/bot/exts/filters/test_antimalware.py @@ -3,8 +3,8 @@ from unittest.mock import AsyncMock, Mock from discord import NotFound -from bot.cogs.filters import antimalware from bot.constants import Channels, STAFF_ROLES +from bot.exts.filters import antimalware from tests.helpers import MockAttachment, MockBot, MockMessage, MockRole diff --git a/tests/bot/cogs/filters/test_antispam.py b/tests/bot/exts/filters/test_antispam.py index 8a3d8d02e..6a0e4fded 100644 --- a/tests/bot/cogs/filters/test_antispam.py +++ b/tests/bot/exts/filters/test_antispam.py @@ -1,6 +1,6 @@ import unittest -from bot.cogs.filters import antispam +from bot.exts.filters import antispam class AntispamConfigurationValidationTests(unittest.TestCase): diff --git a/tests/bot/cogs/filters/test_security.py b/tests/bot/exts/filters/test_security.py index 82679f69c..c0c3baa42 100644 --- a/tests/bot/cogs/filters/test_security.py +++ b/tests/bot/exts/filters/test_security.py @@ -3,7 +3,7 @@ from unittest.mock import MagicMock from discord.ext.commands import NoPrivateMessage -from bot.cogs.filters import security +from bot.exts.filters import security from tests.helpers import MockBot, MockContext diff --git a/tests/bot/cogs/filters/test_token_remover.py b/tests/bot/exts/filters/test_token_remover.py index 55b284ef9..a0ff8a877 100644 --- a/tests/bot/cogs/filters/test_token_remover.py +++ b/tests/bot/exts/filters/test_token_remover.py @@ -6,9 +6,9 @@ from unittest.mock import MagicMock from discord import Colour, NotFound from bot import constants -from bot.cogs.filters import token_remover -from bot.cogs.filters.token_remover import Token, TokenRemover -from bot.cogs.moderation.modlog import ModLog +from bot.exts.filters import token_remover +from bot.exts.filters.token_remover import Token, TokenRemover +from bot.exts.moderation.modlog import ModLog from tests.helpers import MockBot, MockMessage, autospec @@ -132,7 +132,7 @@ class TokenRemoverTests(unittest.IsolatedAsyncioTestCase): await cog.on_message(msg) find_token_in_message.assert_not_called() - @autospec("bot.cogs.filters.token_remover", "TOKEN_RE") + @autospec("bot.exts.filters.token_remover", "TOKEN_RE") def test_find_token_no_matches(self, token_re): """None should be returned if the regex matches no tokens in a message.""" token_re.finditer.return_value = () @@ -143,8 +143,8 @@ class TokenRemoverTests(unittest.IsolatedAsyncioTestCase): token_re.finditer.assert_called_once_with(self.msg.content) @autospec(TokenRemover, "is_valid_user_id", "is_valid_timestamp") - @autospec("bot.cogs.filters.token_remover", "Token") - @autospec("bot.cogs.filters.token_remover", "TOKEN_RE") + @autospec("bot.exts.filters.token_remover", "Token") + @autospec("bot.exts.filters.token_remover", "TOKEN_RE") def test_find_token_valid_match(self, token_re, token_cls, is_valid_id, is_valid_timestamp): """The first match with a valid user ID and timestamp should be returned as a `Token`.""" matches = [ @@ -167,8 +167,8 @@ class TokenRemoverTests(unittest.IsolatedAsyncioTestCase): token_re.finditer.assert_called_once_with(self.msg.content) @autospec(TokenRemover, "is_valid_user_id", "is_valid_timestamp") - @autospec("bot.cogs.filters.token_remover", "Token") - @autospec("bot.cogs.filters.token_remover", "TOKEN_RE") + @autospec("bot.exts.filters.token_remover", "Token") + @autospec("bot.exts.filters.token_remover", "TOKEN_RE") def test_find_token_invalid_matches(self, token_re, token_cls, is_valid_id, is_valid_timestamp): """None should be returned if no matches have valid user IDs or timestamps.""" token_re.finditer.return_value = [mock.create_autospec(Match, spec_set=True, instance=True)] @@ -230,7 +230,7 @@ class TokenRemoverTests(unittest.IsolatedAsyncioTestCase): results = [match[0] for match in results] self.assertCountEqual((token_1, token_2), results) - @autospec("bot.cogs.filters.token_remover", "LOG_MESSAGE") + @autospec("bot.exts.filters.token_remover", "LOG_MESSAGE") def test_format_log_message(self, log_message): """Should correctly format the log message with info from the message and token.""" token = Token("NDY3MjIzMjMwNjUwNzc3NjQx", "XsySD_", "s45jqDV_Iisn-symw0yDRrk_jf4") @@ -249,7 +249,7 @@ class TokenRemoverTests(unittest.IsolatedAsyncioTestCase): ) @mock.patch.object(TokenRemover, "mod_log", new_callable=mock.PropertyMock) - @autospec("bot.cogs.filters.token_remover", "log") + @autospec("bot.exts.filters.token_remover", "log") @autospec(TokenRemover, "format_log_message") async def test_take_action(self, format_log_message, logger, mod_log_property): """Should delete the message and send a mod log.""" @@ -299,7 +299,7 @@ class TokenRemoverTests(unittest.IsolatedAsyncioTestCase): class TokenRemoverExtensionTests(unittest.TestCase): """Tests for the token_remover extension.""" - @autospec("bot.cogs.filters.token_remover", "TokenRemover") + @autospec("bot.exts.filters.token_remover", "TokenRemover") def test_extension_setup(self, cog): """The TokenRemover cog should be added.""" bot = MockBot() diff --git a/tests/bot/cogs/info/__init__.py b/tests/bot/exts/info/__init__.py index e69de29bb..e69de29bb 100644 --- a/tests/bot/cogs/info/__init__.py +++ b/tests/bot/exts/info/__init__.py diff --git a/tests/bot/cogs/info/test_information.py b/tests/bot/exts/info/test_information.py index 895a8328e..be47d42ef 100644 --- a/tests/bot/cogs/info/test_information.py +++ b/tests/bot/exts/info/test_information.py @@ -6,11 +6,11 @@ import unittest.mock import discord from bot import constants -from bot.cogs.info import information +from bot.exts.info import information from bot.utils.checks import InWhitelistCheckFailure from tests import helpers -COG_PATH = "bot.cogs.info.information.Information" +COG_PATH = "bot.exts.info.information.Information" class InformationCogTests(unittest.TestCase): @@ -97,7 +97,7 @@ class InformationCogTests(unittest.TestCase): self.assertEqual(admin_embed.title, "Admins info") self.assertEqual(admin_embed.colour, discord.Colour.red()) - @unittest.mock.patch('bot.cogs.info.information.time_since') + @unittest.mock.patch('bot.exts.info.information.time_since') def test_server_info_command(self, time_since_patch): time_since_patch.return_value = '2 days ago' @@ -339,8 +339,8 @@ class UserInfractionHelperMethodTests(unittest.TestCase): self._method_subtests(self.cog.user_nomination_counts, test_values, header) [email protected]("bot.cogs.info.information.time_since", new=unittest.mock.MagicMock(return_value="1 year ago")) [email protected]("bot.cogs.info.information.constants.MODERATION_CHANNELS", new=[50]) [email protected]("bot.exts.info.information.time_since", new=unittest.mock.MagicMock(return_value="1 year ago")) [email protected]("bot.exts.info.information.constants.MODERATION_CHANNELS", new=[50]) class UserEmbedTests(unittest.TestCase): """Tests for the creation of the `!user` embed.""" @@ -492,7 +492,7 @@ class UserEmbedTests(unittest.TestCase): self.assertEqual(embed.thumbnail.url, "avatar url") [email protected]("bot.cogs.info.information.constants") [email protected]("bot.exts.info.information.constants") class UserCommandTests(unittest.TestCase): """Tests for the `!user` command.""" @@ -531,7 +531,7 @@ class UserCommandTests(unittest.TestCase): with self.assertRaises(InWhitelistCheckFailure, msg=msg): asyncio.run(self.cog.user_info.callback(self.cog, ctx)) - @unittest.mock.patch("bot.cogs.info.information.Information.create_user_embed") + @unittest.mock.patch("bot.exts.info.information.Information.create_user_embed") def test_regular_user_may_use_command_in_bot_commands_channel(self, create_embed, constants): """A regular user should be allowed to use `!user` targeting themselves in bot-commands.""" constants.STAFF_ROLES = [self.moderator_role.id] @@ -544,7 +544,7 @@ class UserCommandTests(unittest.TestCase): create_embed.assert_called_once_with(ctx, self.author) ctx.send.assert_called_once() - @unittest.mock.patch("bot.cogs.info.information.Information.create_user_embed") + @unittest.mock.patch("bot.exts.info.information.Information.create_user_embed") def test_regular_user_can_explicitly_target_themselves(self, create_embed, constants): """A user should target itself with `!user` when a `user` argument was not provided.""" constants.STAFF_ROLES = [self.moderator_role.id] @@ -557,7 +557,7 @@ class UserCommandTests(unittest.TestCase): create_embed.assert_called_once_with(ctx, self.author) ctx.send.assert_called_once() - @unittest.mock.patch("bot.cogs.info.information.Information.create_user_embed") + @unittest.mock.patch("bot.exts.info.information.Information.create_user_embed") def test_staff_members_can_bypass_channel_restriction(self, create_embed, constants): """Staff members should be able to bypass the bot-commands channel restriction.""" constants.STAFF_ROLES = [self.moderator_role.id] @@ -570,7 +570,7 @@ class UserCommandTests(unittest.TestCase): create_embed.assert_called_once_with(ctx, self.moderator) ctx.send.assert_called_once() - @unittest.mock.patch("bot.cogs.info.information.Information.create_user_embed") + @unittest.mock.patch("bot.exts.info.information.Information.create_user_embed") def test_moderators_can_target_another_member(self, create_embed, constants): """A moderator should be able to use `!user` targeting another user.""" constants.MODERATION_ROLES = [self.moderator_role.id] diff --git a/tests/bot/cogs/moderation/__init__.py b/tests/bot/exts/moderation/__init__.py index e69de29bb..e69de29bb 100644 --- a/tests/bot/cogs/moderation/__init__.py +++ b/tests/bot/exts/moderation/__init__.py diff --git a/tests/bot/cogs/moderation/infraction/__init__.py b/tests/bot/exts/moderation/infraction/__init__.py index e69de29bb..e69de29bb 100644 --- a/tests/bot/cogs/moderation/infraction/__init__.py +++ b/tests/bot/exts/moderation/infraction/__init__.py diff --git a/tests/bot/cogs/moderation/infraction/test_infractions.py b/tests/bot/exts/moderation/infraction/test_infractions.py index 2df61d431..be1b649e1 100644 --- a/tests/bot/cogs/moderation/infraction/test_infractions.py +++ b/tests/bot/exts/moderation/infraction/test_infractions.py @@ -2,7 +2,7 @@ import textwrap import unittest from unittest.mock import AsyncMock, Mock, patch -from bot.cogs.moderation.infraction.infractions import Infractions +from bot.exts.moderation.infraction.infractions import Infractions from tests.helpers import MockBot, MockContext, MockGuild, MockMember, MockRole @@ -17,8 +17,8 @@ class TruncationTests(unittest.IsolatedAsyncioTestCase): self.guild = MockGuild(id=4567) self.ctx = MockContext(bot=self.bot, author=self.user, guild=self.guild) - @patch("bot.cogs.moderation.infraction._utils.get_active_infraction") - @patch("bot.cogs.moderation.infraction._utils.post_infraction") + @patch("bot.exts.moderation.infraction._utils.get_active_infraction") + @patch("bot.exts.moderation.infraction._utils.post_infraction") async def test_apply_ban_reason_truncation(self, post_infraction_mock, get_active_mock): """Should truncate reason for `ctx.guild.ban`.""" get_active_mock.return_value = None @@ -39,7 +39,7 @@ class TruncationTests(unittest.IsolatedAsyncioTestCase): self.ctx, {"foo": "bar"}, self.target, self.ctx.guild.ban.return_value ) - @patch("bot.cogs.moderation.infraction._utils.post_infraction") + @patch("bot.exts.moderation.infraction._utils.post_infraction") async def test_apply_kick_reason_truncation(self, post_infraction_mock): """Should truncate reason for `Member.kick`.""" post_infraction_mock.return_value = {"foo": "bar"} diff --git a/tests/bot/cogs/moderation/test_incidents.py b/tests/bot/exts/moderation/test_incidents.py index 5e4d90251..cbf7f7bcf 100644 --- a/tests/bot/cogs/moderation/test_incidents.py +++ b/tests/bot/exts/moderation/test_incidents.py @@ -8,8 +8,8 @@ from unittest.mock import AsyncMock, MagicMock, call, patch import aiohttp import discord -from bot.cogs.moderation import incidents from bot.constants import Colours +from bot.exts.moderation import incidents from tests.helpers import ( MockAsyncWebhook, MockAttachment, @@ -130,7 +130,7 @@ class TestMakeEmbed(unittest.IsolatedAsyncioTestCase): incident = MockMessage(content="this is an incident", attachments=[attachment]) # Patch `download_file` to return our `file` - with patch("bot.cogs.moderation.incidents.download_file", AsyncMock(return_value=file)): + with patch("bot.exts.moderation.incidents.download_file", AsyncMock(return_value=file)): embed, returned_file = await incidents.make_embed(incident, incidents.Signal.ACTIONED, MockMember()) self.assertIs(file, returned_file) @@ -142,7 +142,7 @@ class TestMakeEmbed(unittest.IsolatedAsyncioTestCase): incident = MockMessage(content="this is an incident", attachments=[attachment]) # Patch `download_file` to return None as if the download failed - with patch("bot.cogs.moderation.incidents.download_file", AsyncMock(return_value=None)): + with patch("bot.exts.moderation.incidents.download_file", AsyncMock(return_value=None)): embed, returned_file = await incidents.make_embed(incident, incidents.Signal.ACTIONED, MockMember()) self.assertIsNone(returned_file) @@ -215,7 +215,7 @@ class TestOwnReactions(unittest.TestCase): self.assertSetEqual(incidents.own_reactions(message), {"A", "B"}) -@patch("bot.cogs.moderation.incidents.ALL_SIGNALS", {"A", "B"}) +@patch("bot.exts.moderation.incidents.ALL_SIGNALS", {"A", "B"}) class TestHasSignals(unittest.TestCase): """ Assertions for the `has_signals` function. @@ -229,7 +229,7 @@ class TestHasSignals(unittest.TestCase): message = MockMessage() own_reactions = MagicMock(return_value={"A", "B"}) - with patch("bot.cogs.moderation.incidents.own_reactions", own_reactions): + with patch("bot.exts.moderation.incidents.own_reactions", own_reactions): self.assertTrue(incidents.has_signals(message)) def test_has_signals_false(self): @@ -237,11 +237,11 @@ class TestHasSignals(unittest.TestCase): message = MockMessage() own_reactions = MagicMock(return_value={"A", "C"}) - with patch("bot.cogs.moderation.incidents.own_reactions", own_reactions): + with patch("bot.exts.moderation.incidents.own_reactions", own_reactions): self.assertFalse(incidents.has_signals(message)) -@patch("bot.cogs.moderation.incidents.Signal", MockSignal) +@patch("bot.exts.moderation.incidents.Signal", MockSignal) class TestAddSignals(unittest.IsolatedAsyncioTestCase): """ Assertions for the `add_signals` coroutine. @@ -255,19 +255,19 @@ class TestAddSignals(unittest.IsolatedAsyncioTestCase): """Prepare a mock incident message for tests to use.""" self.incident = MockMessage() - @patch("bot.cogs.moderation.incidents.own_reactions", MagicMock(return_value=set())) + @patch("bot.exts.moderation.incidents.own_reactions", MagicMock(return_value=set())) async def test_add_signals_missing(self): """All emoji are added when none are present.""" await incidents.add_signals(self.incident) self.incident.add_reaction.assert_has_calls([call("A"), call("B")]) - @patch("bot.cogs.moderation.incidents.own_reactions", MagicMock(return_value={"A"})) + @patch("bot.exts.moderation.incidents.own_reactions", MagicMock(return_value={"A"})) async def test_add_signals_partial(self): """Only missing emoji are added when some are present.""" await incidents.add_signals(self.incident) self.incident.add_reaction.assert_has_calls([call("B")]) - @patch("bot.cogs.moderation.incidents.own_reactions", MagicMock(return_value={"A", "B"})) + @patch("bot.exts.moderation.incidents.own_reactions", MagicMock(return_value={"A", "B"})) async def test_add_signals_present(self): """No emoji are added when all are present.""" await incidents.add_signals(self.incident) @@ -326,25 +326,25 @@ class TestCrawlIncidents(TestIncidents): await self.cog_instance.crawl_incidents() self.cog_instance.bot.wait_until_guild_available.assert_awaited() - @patch("bot.cogs.moderation.incidents.add_signals", AsyncMock()) - @patch("bot.cogs.moderation.incidents.is_incident", MagicMock(return_value=False)) # Message doesn't qualify - @patch("bot.cogs.moderation.incidents.has_signals", MagicMock(return_value=False)) + @patch("bot.exts.moderation.incidents.add_signals", AsyncMock()) + @patch("bot.exts.moderation.incidents.is_incident", MagicMock(return_value=False)) # Message doesn't qualify + @patch("bot.exts.moderation.incidents.has_signals", MagicMock(return_value=False)) async def test_crawl_incidents_noop_if_is_not_incident(self): """Signals are not added for a non-incident message.""" await self.cog_instance.crawl_incidents() incidents.add_signals.assert_not_awaited() - @patch("bot.cogs.moderation.incidents.add_signals", AsyncMock()) - @patch("bot.cogs.moderation.incidents.is_incident", MagicMock(return_value=True)) # Message qualifies - @patch("bot.cogs.moderation.incidents.has_signals", MagicMock(return_value=True)) # But already has signals + @patch("bot.exts.moderation.incidents.add_signals", AsyncMock()) + @patch("bot.exts.moderation.incidents.is_incident", MagicMock(return_value=True)) # Message qualifies + @patch("bot.exts.moderation.incidents.has_signals", MagicMock(return_value=True)) # But already has signals async def test_crawl_incidents_noop_if_message_already_has_signals(self): """Signals are not added for messages which already have them.""" await self.cog_instance.crawl_incidents() incidents.add_signals.assert_not_awaited() - @patch("bot.cogs.moderation.incidents.add_signals", AsyncMock()) - @patch("bot.cogs.moderation.incidents.is_incident", MagicMock(return_value=True)) # Message qualifies - @patch("bot.cogs.moderation.incidents.has_signals", MagicMock(return_value=False)) # And doesn't have signals + @patch("bot.exts.moderation.incidents.add_signals", AsyncMock()) + @patch("bot.exts.moderation.incidents.is_incident", MagicMock(return_value=True)) # Message qualifies + @patch("bot.exts.moderation.incidents.has_signals", MagicMock(return_value=False)) # And doesn't have signals async def test_crawl_incidents_add_signals_called(self): """Message has signals added as it does not have them yet and qualifies as an incident.""" await self.cog_instance.crawl_incidents() @@ -384,7 +384,7 @@ class TestArchive(TestIncidents): ) built_embed = MagicMock(discord.Embed, id=123) # We patch `make_embed` to return this - with patch("bot.cogs.moderation.incidents.make_embed", AsyncMock(return_value=(built_embed, None))): + with patch("bot.exts.moderation.incidents.make_embed", AsyncMock(return_value=(built_embed, None))): archive_return = await self.cog_instance.archive(incident, MagicMock(value="A"), MockMember()) # Now we check that the webhook was given the correct args, and that `archive` returned True @@ -451,8 +451,8 @@ class TestMakeConfirmationTask(TestIncidents): self.assertFalse(created_check(payload=MagicMock(message_id=0))) -@patch("bot.cogs.moderation.incidents.ALLOWED_ROLES", {1, 2}) -@patch("bot.cogs.moderation.incidents.Incidents.make_confirmation_task", AsyncMock()) # Generic awaitable +@patch("bot.exts.moderation.incidents.ALLOWED_ROLES", {1, 2}) +@patch("bot.exts.moderation.incidents.Incidents.make_confirmation_task", AsyncMock()) # Generic awaitable class TestProcessEvent(TestIncidents): """Tests for the `Incidents.process_event` coroutine.""" @@ -479,7 +479,7 @@ class TestProcessEvent(TestIncidents): async def test_process_event_no_archive_on_investigating(self): """Message is not archived on `Signal.INVESTIGATING`.""" - with patch("bot.cogs.moderation.incidents.Incidents.archive", AsyncMock()) as mocked_archive: + with patch("bot.exts.moderation.incidents.Incidents.archive", AsyncMock()) as mocked_archive: await self.cog_instance.process_event( reaction=incidents.Signal.INVESTIGATING.value, incident=MockMessage(), @@ -497,7 +497,7 @@ class TestProcessEvent(TestIncidents): """ incident = MockMessage() - with patch("bot.cogs.moderation.incidents.Incidents.archive", AsyncMock(return_value=False)): + with patch("bot.exts.moderation.incidents.Incidents.archive", AsyncMock(return_value=False)): await self.cog_instance.process_event( reaction=incidents.Signal.ACTIONED.value, incident=incident, @@ -510,7 +510,7 @@ class TestProcessEvent(TestIncidents): """Task given by `Incidents.make_confirmation_task` is awaited before method exits.""" mock_task = AsyncMock() - with patch("bot.cogs.moderation.incidents.Incidents.make_confirmation_task", mock_task): + with patch("bot.exts.moderation.incidents.Incidents.make_confirmation_task", mock_task): await self.cog_instance.process_event( reaction=incidents.Signal.ACTIONED.value, incident=MockMessage(), @@ -530,7 +530,7 @@ class TestProcessEvent(TestIncidents): mock_task = AsyncMock(side_effect=asyncio.TimeoutError()) try: - with patch("bot.cogs.moderation.incidents.Incidents.make_confirmation_task", mock_task): + with patch("bot.exts.moderation.incidents.Incidents.make_confirmation_task", mock_task): await self.cog_instance.process_event( reaction=incidents.Signal.ACTIONED.value, incident=MockMessage(), @@ -712,7 +712,7 @@ class TestOnRawReactionAdd(TestIncidents): self.cog_instance.process_event = AsyncMock() self.cog_instance.resolve_message = AsyncMock(return_value=MockMessage()) - with patch("bot.cogs.moderation.incidents.is_incident", MagicMock(return_value=False)): + with patch("bot.exts.moderation.incidents.is_incident", MagicMock(return_value=False)): await self.cog_instance.on_raw_reaction_add(self.payload) self.cog_instance.process_event.assert_not_called() @@ -733,7 +733,7 @@ class TestOnRawReactionAdd(TestIncidents): self.cog_instance.process_event = AsyncMock() self.cog_instance.resolve_message = AsyncMock(return_value=incident) - with patch("bot.cogs.moderation.incidents.is_incident", MagicMock(return_value=True)): + with patch("bot.exts.moderation.incidents.is_incident", MagicMock(return_value=True)): await self.cog_instance.on_raw_reaction_add(self.payload) self.cog_instance.process_event.assert_called_with( @@ -751,20 +751,20 @@ class TestOnMessage(TestIncidents): function is tested in `TestIsIncident` - here we do not worry about it. """ - @patch("bot.cogs.moderation.incidents.is_incident", MagicMock(return_value=True)) + @patch("bot.exts.moderation.incidents.is_incident", MagicMock(return_value=True)) async def test_on_message_incident(self): """Messages qualifying as incidents are passed to `add_signals`.""" incident = MockMessage() - with patch("bot.cogs.moderation.incidents.add_signals", AsyncMock()) as mock_add_signals: + with patch("bot.exts.moderation.incidents.add_signals", AsyncMock()) as mock_add_signals: await self.cog_instance.on_message(incident) mock_add_signals.assert_called_once_with(incident) - @patch("bot.cogs.moderation.incidents.is_incident", MagicMock(return_value=False)) + @patch("bot.exts.moderation.incidents.is_incident", MagicMock(return_value=False)) async def test_on_message_non_incident(self): """Messages not qualifying as incidents are ignored.""" - with patch("bot.cogs.moderation.incidents.add_signals", AsyncMock()) as mock_add_signals: + with patch("bot.exts.moderation.incidents.add_signals", AsyncMock()) as mock_add_signals: await self.cog_instance.on_message(MockMessage()) mock_add_signals.assert_not_called() diff --git a/tests/bot/cogs/moderation/test_modlog.py b/tests/bot/exts/moderation/test_modlog.py index f2809f40a..f8f142484 100644 --- a/tests/bot/cogs/moderation/test_modlog.py +++ b/tests/bot/exts/moderation/test_modlog.py @@ -2,7 +2,7 @@ import unittest import discord -from bot.cogs.moderation.modlog import ModLog +from bot.exts.moderation.modlog import ModLog from tests.helpers import MockBot, MockTextChannel diff --git a/tests/bot/cogs/moderation/test_silence.py b/tests/bot/exts/moderation/test_silence.py index ab3d0742a..8c4fb764a 100644 --- a/tests/bot/cogs/moderation/test_silence.py +++ b/tests/bot/exts/moderation/test_silence.py @@ -4,8 +4,8 @@ from unittest.mock import MagicMock, Mock from discord import PermissionOverwrite -from bot.cogs.moderation.silence import Silence, SilenceNotifier from bot.constants import Channels, Emojis, Guild, Roles +from bot.exts.moderation.silence import Silence, SilenceNotifier from tests.helpers import MockBot, MockContext, MockTextChannel @@ -99,7 +99,7 @@ class SilenceTests(unittest.IsolatedAsyncioTestCase): self.bot.get_channel.called_once_with(Channels.mod_alerts) self.bot.get_channel.called_once_with(Channels.mod_log) - @mock.patch("bot.cogs.moderation.silence.SilenceNotifier") + @mock.patch("bot.exts.moderation.silence.SilenceNotifier") async def test_instance_vars_got_notifier(self, notifier): """Notifier was started with channel.""" mod_log = MockTextChannel() @@ -238,7 +238,7 @@ class SilenceTests(unittest.IsolatedAsyncioTestCase): del mock_permissions_dict['send_messages'] self.assertDictEqual(mock_permissions_dict, new_permissions) - @mock.patch("bot.cogs.moderation.silence.asyncio") + @mock.patch("bot.exts.moderation.silence.asyncio") @mock.patch.object(Silence, "_mod_alerts_channel", create=True) def test_cog_unload_starts_task(self, alert_channel, asyncio_mock): """Task for sending an alert was created with present `muted_channels`.""" @@ -247,14 +247,14 @@ class SilenceTests(unittest.IsolatedAsyncioTestCase): alert_channel.send.assert_called_once_with(f"<@&{Roles.moderators}> channels left silenced on cog unload: ") asyncio_mock.create_task.assert_called_once_with(alert_channel.send()) - @mock.patch("bot.cogs.moderation.silence.asyncio") + @mock.patch("bot.exts.moderation.silence.asyncio") def test_cog_unload_skips_task_start(self, asyncio_mock): """No task created with no channels.""" self.cog.cog_unload() asyncio_mock.create_task.assert_not_called() - @mock.patch("bot.cogs.moderation.silence.with_role_check") - @mock.patch("bot.cogs.moderation.silence.MODERATION_ROLES", new=(1, 2, 3)) + @mock.patch("bot.exts.moderation.silence.with_role_check") + @mock.patch("bot.exts.moderation.silence.MODERATION_ROLES", new=(1, 2, 3)) def test_cog_check(self, role_check): """Role check is called with `MODERATION_ROLES`""" self.cog.cog_check(self.ctx) diff --git a/tests/bot/cogs/moderation/test_slowmode.py b/tests/bot/exts/moderation/test_slowmode.py index f442814c8..e90394ab9 100644 --- a/tests/bot/cogs/moderation/test_slowmode.py +++ b/tests/bot/exts/moderation/test_slowmode.py @@ -3,8 +3,8 @@ from unittest import mock from dateutil.relativedelta import relativedelta -from bot.cogs.moderation.slowmode import Slowmode from bot.constants import Emojis +from bot.exts.moderation.slowmode import Slowmode from tests.helpers import MockBot, MockContext, MockTextChannel @@ -103,8 +103,8 @@ class SlowmodeTests(unittest.IsolatedAsyncioTestCase): f'{Emojis.check_mark} The slowmode delay for #meta has been reset to 0 seconds.' ) - @mock.patch("bot.cogs.moderation.slowmode.with_role_check") - @mock.patch("bot.cogs.moderation.slowmode.MODERATION_ROLES", new=(1, 2, 3)) + @mock.patch("bot.exts.moderation.slowmode.with_role_check") + @mock.patch("bot.exts.moderation.slowmode.MODERATION_ROLES", new=(1, 2, 3)) def test_cog_check(self, role_check): """Role check is called with `MODERATION_ROLES`""" self.cog.cog_check(self.ctx) diff --git a/tests/bot/cogs/test_cogs.py b/tests/bot/exts/test_cogs.py index fdda59a8f..775c40722 100644 --- a/tests/bot/cogs/test_cogs.py +++ b/tests/bot/exts/test_cogs.py @@ -10,7 +10,7 @@ from unittest import mock from discord.ext import commands -from bot import cogs +from bot import exts class CommandNameTests(unittest.TestCase): @@ -29,13 +29,14 @@ class CommandNameTests(unittest.TestCase): @staticmethod def walk_modules() -> t.Iterator[ModuleType]: - """Yield imported modules from the bot.cogs subpackage.""" + """Yield imported modules from the bot.exts subpackage.""" def on_error(name: str) -> t.NoReturn: raise ImportError(name=name) # pragma: no cover # The mock prevents asyncio.get_event_loop() from being called. with mock.patch("discord.ext.tasks.loop"): - for module in pkgutil.walk_packages(cogs.__path__, "bot.cogs.", onerror=on_error): + prefix = f"{exts.__name__}." + for module in pkgutil.walk_packages(exts.__path__, prefix, onerror=on_error): if not module.ispkg: yield importlib.import_module(module.name) diff --git a/tests/bot/cogs/test_duck_pond.py b/tests/bot/exts/test_duck_pond.py index cfe10aebf..f6d977482 100644 --- a/tests/bot/cogs/test_duck_pond.py +++ b/tests/bot/exts/test_duck_pond.py @@ -7,11 +7,11 @@ from unittest.mock import AsyncMock, MagicMock, patch import discord from bot import constants -from bot.cogs import duck_pond +from bot.exts import duck_pond from tests import base from tests import helpers -MODULE_PATH = "bot.cogs.duck_pond" +MODULE_PATH = "bot.exts.duck_pond" class DuckPondTests(base.LoggingTestsMixin, unittest.IsolatedAsyncioTestCase): @@ -63,7 +63,7 @@ class DuckPondTests(base.LoggingTestsMixin, unittest.IsolatedAsyncioTestCase): self.bot.fetch_webhook.side_effect = discord.HTTPException(response=MagicMock(), message="Not found.") self.cog.webhook_id = 1 - log = logging.getLogger('bot.cogs.duck_pond') + log = logging.getLogger('bot.exts.duck_pond') with self.assertLogs(logger=log, level=logging.ERROR) as log_watcher: asyncio.run(self.cog.fetch_webhook()) @@ -282,7 +282,7 @@ class DuckPondTests(base.LoggingTestsMixin, unittest.IsolatedAsyncioTestCase): side_effects = (discord.errors.Forbidden(MagicMock(), ""), discord.errors.NotFound(MagicMock(), "")) self.cog.webhook = helpers.MockAsyncWebhook() - log = logging.getLogger("bot.cogs.duck_pond") + log = logging.getLogger("bot.exts.duck_pond") for side_effect in side_effects: # pragma: no cover send_attachments.side_effect = side_effect @@ -300,7 +300,7 @@ class DuckPondTests(base.LoggingTestsMixin, unittest.IsolatedAsyncioTestCase): message = helpers.MockMessage(clean_content="message", attachments=["attachment"]) self.cog.webhook = helpers.MockAsyncWebhook() - log = logging.getLogger("bot.cogs.duck_pond") + log = logging.getLogger("bot.exts.duck_pond") side_effect = discord.HTTPException(MagicMock(), "") send_attachments.side_effect = side_effect diff --git a/tests/bot/cogs/utils/__init__.py b/tests/bot/exts/utils/__init__.py index e69de29bb..e69de29bb 100644 --- a/tests/bot/cogs/utils/__init__.py +++ b/tests/bot/exts/utils/__init__.py diff --git a/tests/bot/cogs/utils/test_jams.py b/tests/bot/exts/utils/test_jams.py index 299f436ba..45e7b5b51 100644 --- a/tests/bot/cogs/utils/test_jams.py +++ b/tests/bot/exts/utils/test_jams.py @@ -3,8 +3,8 @@ from unittest.mock import AsyncMock, MagicMock, create_autospec from discord import CategoryChannel -from bot.cogs.utils import jams from bot.constants import Roles +from bot.exts.utils import jams from tests.helpers import MockBot, MockContext, MockGuild, MockMember, MockRole, MockTextChannel diff --git a/tests/bot/cogs/utils/test_snekbox.py b/tests/bot/exts/utils/test_snekbox.py index 3e447f319..f7b861035 100644 --- a/tests/bot/cogs/utils/test_snekbox.py +++ b/tests/bot/exts/utils/test_snekbox.py @@ -6,8 +6,8 @@ from unittest.mock import AsyncMock, MagicMock, Mock, call, create_autospec, pat from discord.ext import commands from bot import constants -from bot.cogs.utils import snekbox -from bot.cogs.utils.snekbox import Snekbox +from bot.exts.utils import snekbox +from bot.exts.utils.snekbox import Snekbox from tests.helpers import MockBot, MockContext, MockMessage, MockReaction, MockUser @@ -68,7 +68,7 @@ class SnekboxTests(unittest.IsolatedAsyncioTestCase): context_manager.__aenter__.return_value = resp self.bot.http_session.post.return_value = context_manager - log = logging.getLogger("bot.cogs.utils.snekbox") + log = logging.getLogger("bot.exts.utils.snekbox") with self.assertLogs(logger=log, level='ERROR'): await self.cog.upload_output('My awesome output!') @@ -99,14 +99,14 @@ class SnekboxTests(unittest.IsolatedAsyncioTestCase): actual = self.cog.get_results_message({'stdout': stdout, 'returncode': returncode}) self.assertEqual(actual, expected) - @patch('bot.cogs.utils.snekbox.Signals', side_effect=ValueError) + @patch('bot.exts.utils.snekbox.Signals', side_effect=ValueError) def test_get_results_message_invalid_signal(self, mock_signals: Mock): self.assertEqual( self.cog.get_results_message({'stdout': '', 'returncode': 127}), ('Your eval job has completed with return code 127', '') ) - @patch('bot.cogs.utils.snekbox.Signals') + @patch('bot.exts.utils.snekbox.Signals') def test_get_results_message_valid_signal(self, mock_signals: Mock): mock_signals.return_value.name = 'SIGTEST' self.assertEqual( @@ -296,7 +296,7 @@ class SnekboxTests(unittest.IsolatedAsyncioTestCase): self.cog.get_results_message.assert_called_once_with({'stdout': 'ERROR', 'returncode': 127}) self.cog.format_output.assert_not_called() - @patch("bot.cogs.utils.snekbox.partial") + @patch("bot.exts.utils.snekbox.partial") async def test_continue_eval_does_continue(self, partial_mock): """Test that the continue_eval function does continue if required conditions are met.""" ctx = MockContext(message=MockMessage(add_reaction=AsyncMock(), clear_reactions=AsyncMock())) |