aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar mbaruh <[email protected]>2022-02-22 22:15:19 +0200
committerGravatar mbaruh <[email protected]>2022-07-16 02:07:25 +0300
commitd1ae7ce9235e4d63ee1dde282ca890ac5509f950 (patch)
tree236cc81b3f6574c3a75e737c4bc9b3926c91a55e /tests
parentAdd listing commands (diff)
Accept strings in channel scope and change role string interpretation
The channel scope settings were changed to accomodate strings. That means that if a string is specified, the bot will look whether the context channel's name matches. If it's a number, it will match the ID. Accordingly the same changed was applied to the bypass roles and pings settings: if it's a non-numeric string, it will look for a role with that name.
Diffstat (limited to 'tests')
-rw-r--r--tests/bot/exts/filtering/test_settings_entries.py8
-rw-r--r--tests/helpers.py2
2 files changed, 5 insertions, 5 deletions
diff --git a/tests/bot/exts/filtering/test_settings_entries.py b/tests/bot/exts/filtering/test_settings_entries.py
index 4db6438ab..d18861bd6 100644
--- a/tests/bot/exts/filtering/test_settings_entries.py
+++ b/tests/bot/exts/filtering/test_settings_entries.py
@@ -62,7 +62,7 @@ class FilterTests(unittest.TestCase):
def test_context_doesnt_trigger_for_disabled_channel(self):
"""A filter shouldn't trigger if it's been disabled in the channel."""
channel = MockTextChannel(id=123)
- scope = ChannelScope({"disabled_channels": [123], "disabled_categories": None, "enabled_channels": None})
+ scope = ChannelScope({"disabled_channels": ["123"], "disabled_categories": None, "enabled_channels": None})
self.ctx.channel = channel
result = scope.triggers_on(self.ctx)
@@ -71,9 +71,9 @@ class FilterTests(unittest.TestCase):
def test_context_doesnt_trigger_in_disabled_category(self):
"""A filter shouldn't trigger if it's been disabled in the category."""
- channel = MockTextChannel()
+ channel = MockTextChannel(category=MockCategoryChannel(id=456))
scope = ChannelScope({
- "disabled_channels": None, "disabled_categories": [channel.category.id], "enabled_channels": None
+ "disabled_channels": None, "disabled_categories": ["456"], "enabled_channels": None
})
self.ctx.channel = channel
@@ -84,7 +84,7 @@ class FilterTests(unittest.TestCase):
def test_context_triggers_in_enabled_channel_in_disabled_category(self):
"""A filter should trigger in an enabled channel even if it's been disabled in the category."""
channel = MockTextChannel(id=123, category=MockCategoryChannel(id=234))
- scope = ChannelScope({"disabled_channels": None, "disabled_categories": [234], "enabled_channels": [123]})
+ scope = ChannelScope({"disabled_channels": None, "disabled_categories": ["234"], "enabled_channels": ["123"]})
self.ctx.channel = channel
result = scope.triggers_on(self.ctx)
diff --git a/tests/helpers.py b/tests/helpers.py
index 17214553c..e74306d23 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -423,7 +423,7 @@ category_channel_instance = discord.CategoryChannel(
class MockCategoryChannel(CustomMockMixin, unittest.mock.Mock, HashableMixin):
def __init__(self, **kwargs) -> None:
default_kwargs = {'id': next(self.discord_id)}
- super().__init__(**collections.ChainMap(default_kwargs, kwargs))
+ super().__init__(**collections.ChainMap(kwargs, default_kwargs))
# Create a Message instance to get a realistic MagicMock of `discord.Message`