From 37608d6096cb45847c68273a65c3bbe862c2e8a4 Mon Sep 17 00:00:00 2001 From: Johannes Christ Date: Mon, 18 Feb 2019 21:04:05 +0100 Subject: Add unit test for the new validator. --- api/tests/test_validators.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/api/tests/test_validators.py b/api/tests/test_validators.py index 0f3f7fa9..d2c0a136 100644 --- a/api/tests/test_validators.py +++ b/api/tests/test_validators.py @@ -1,7 +1,10 @@ from django.core.exceptions import ValidationError from django.test import TestCase -from ..validators import validate_tag_embed +from ..validators import ( + validate_bot_setting_name, + validate_tag_embed +) REQUIRED_KEYS = ( @@ -9,6 +12,14 @@ REQUIRED_KEYS = ( ) +class BotSettingValidatorTests(TestCase): + def test_accepts_valid_names(self): + validate_bot_setting_name('defcon') + + def test_rejects_bad_names(self): + with self.assertRaises(ValidationError): + validate_bot_setting_name('bad name') + class TagEmbedValidatorTests(TestCase): def test_rejects_non_mapping(self): with self.assertRaises(ValidationError): -- cgit v1.2.3