aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar kwzrd <[email protected]>2019-11-14 20:18:57 +0100
committerGravatar kwzrd <[email protected]>2019-11-14 20:18:57 +0100
commit37b526f372ebc981f5691c5aca1ca8c721da77f6 (patch)
tree0cf294e62ff1c2ea65df0ea15a77a8222110a4bc
parentAdjust attachments rule unit test to correcty build the arguments for the tes... (diff)
Hold recent_messages in a list to respect type hint, set config in setUp
-rw-r--r--tests/bot/rules/test_attachments.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/tests/bot/rules/test_attachments.py b/tests/bot/rules/test_attachments.py
index a43741fcc..fa6b63654 100644
--- a/tests/bot/rules/test_attachments.py
+++ b/tests/bot/rules/test_attachments.py
@@ -12,13 +12,16 @@ def msg(total_attachments: int) -> MockMessage:
class AttachmentRuleTests(unittest.TestCase):
"""Tests applying the `attachments` antispam rule."""
+ def setUp(self):
+ self.config = {"max": 5}
+
@async_test
async def test_allows_messages_without_too_many_attachments(self):
"""Messages without too many attachments are allowed as-is."""
cases = (
- (msg(0), msg(0), msg(0)),
- (msg(2), msg(2)),
- (msg(0),),
+ [msg(0), msg(0), msg(0)],
+ [msg(2), msg(2)],
+ [msg(0)],
)
for recent_messages in cases:
@@ -29,7 +32,7 @@ class AttachmentRuleTests(unittest.TestCase):
recent_messages=recent_messages
):
self.assertIsNone(
- await attachments.apply(last_message, recent_messages, {'max': 5})
+ await attachments.apply(last_message, recent_messages, self.config)
)
@async_test
@@ -59,6 +62,6 @@ class AttachmentRuleTests(unittest.TestCase):
total=total
):
self.assertEqual(
- await attachments.apply(last_message, recent_messages, {'max': 5}),
+ await attachments.apply(last_message, recent_messages, self.config),
(f"sent {total} attachments in 5s", ('lemon',), relevant_messages)
)