diff options
author | 2019-09-18 14:00:57 -0700 | |
---|---|---|
committer | 2019-09-18 14:10:06 -0700 | |
commit | 2ac0c6df978f20a488b3eb026753c8a972cb2554 (patch) | |
tree | 43fc70b14b517139dea5324e762ba92a9e211e28 /tests/cogs/test_antispam.py | |
parent | Docstring linting chunk 7 (diff) | |
parent | Merge pull request #436 from python-discord/enhance-offtopicnames-search (diff) |
Merge branch 'master' into flake8-plugins
Diffstat (limited to 'tests/cogs/test_antispam.py')
-rw-r--r-- | tests/cogs/test_antispam.py | 30 |
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 |