aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Numerlor <[email protected]>2020-03-11 18:07:14 +0100
committerGravatar Numerlor <[email protected]>2020-03-11 18:07:14 +0100
commit4740c0fcdc6da6f164963fb34715e78c5d586cec (patch)
tree1e02d3f4244dd585c237f10392cd1a612786f6c0
parentRemove `_current_loop` from setup. (diff)
Add tests for `remove_channel`.
-rw-r--r--tests/bot/cogs/moderation/test_silence.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/bot/cogs/moderation/test_silence.py b/tests/bot/cogs/moderation/test_silence.py
index 2e04dc407..c52ca2a2a 100644
--- a/tests/bot/cogs/moderation/test_silence.py
+++ b/tests/bot/cogs/moderation/test_silence.py
@@ -54,6 +54,24 @@ class SilenceNotifierTests(unittest.IsolatedAsyncioTestCase):
self.notifier.add_channel(Mock())
self.notifier_start_mock.assert_not_called()
+ def test_remove_channel_removes_channel(self):
+ """Channel in FirstHash is removed from `_silenced_channels`."""
+ channel = Mock()
+ with mock.patch.object(self.notifier, "_silenced_channels") as silenced_channels:
+ self.notifier.remove_channel(channel)
+ silenced_channels.remove.assert_called_with(FirstHash(channel))
+
+ def test_remove_channel_stops_loop(self):
+ """Notifier loop is stopped if `_silenced_channels` is empty after remove."""
+ with mock.patch.object(self.notifier, "_silenced_channels", __bool__=lambda _: False):
+ self.notifier.remove_channel(Mock())
+ self.notifier_stop_mock.assert_called_once()
+
+ def test_remove_channel_skips_stop_with_channels(self):
+ """Notifier loop is not stopped if `_silenced_channels` is not empty after remove."""
+ self.notifier.remove_channel(Mock())
+ self.notifier_stop_mock.assert_not_called()
+
class SilenceTests(unittest.IsolatedAsyncioTestCase):
def setUp(self) -> None: