blob: 67900b275690afebdf0968e1ca9223e82ec1bda6 (
plain) (
blame)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 | import pytest
from bot.cogs import antispam
def test_default_antispam_config_is_valid():
    validation_errors = antispam.validate_config()
    assert not validation_errors
@pytest.mark.parametrize(
    ('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
 |