aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2019-09-15 16:06:23 +0200
committerGravatar GitHub <[email protected]>2019-09-15 16:06:23 +0200
commit89356d7f992353c20ea1376e497e266de3577b94 (patch)
tree8d34061eeb3b1e310886964e500bd58bb2c9961c /tests
parentMerge branch 'master' of github.com:python-discord/bot (diff)
parentTypehint the result of `validate_config`. (diff)
Merge pull request #417 from python-discord/validate-antispam-config-in-ci
Validate bot.cogs.antispam configuration on CI.
Diffstat (limited to 'tests')
-rw-r--r--tests/cogs/test_antispam.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/cogs/test_antispam.py b/tests/cogs/test_antispam.py
new file mode 100644
index 000000000..67900b275
--- /dev/null
+++ b/tests/cogs/test_antispam.py
@@ -0,0 +1,30 @@
+import pytest
+
+from bot.cogs import antispam
+
+
+def test_default_antispam_config_is_valid():
+ validation_errors = antispam.validate_config()
+ assert not validation_errors
+
+
+ ('config', 'expected'),
+ (
+ (
+ {'invalid-rule': {}},
+ {'invalid-rule': "`invalid-rule` is not recognized as an antispam rule."}
+ ),
+ (
+ {'burst': {'interval': 10}},
+ {'burst': "Key `max` is required but not set for rule `burst`"}
+ ),
+ (
+ {'burst': {'max': 10}},
+ {'burst': "Key `interval` is required but not set for rule `burst`"}
+ )
+ )
+)
+def test_invalid_antispam_config_returns_validation_errors(config, expected):
+ validation_errors = antispam.validate_config(config)
+ assert validation_errors == expected