aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/config/tests/test_validator.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman_pgp/config/tests/test_validator.py')
-rw-r--r--src/mailman_pgp/config/tests/test_validator.py62
1 files changed, 23 insertions, 39 deletions
diff --git a/src/mailman_pgp/config/tests/test_validator.py b/src/mailman_pgp/config/tests/test_validator.py
index d24dfc7..51570c3 100644
--- a/src/mailman_pgp/config/tests/test_validator.py
+++ b/src/mailman_pgp/config/tests/test_validator.py
@@ -46,72 +46,56 @@ class TestConfigs(TestCase):
class TestValidator(TestCase):
layer = PGPLayer
- def test_builtins(self):
+ def test_missing_section(self):
schema = """\
[test]
- test_option: int
+ test_option: something
"""
validator = ConfigValidator(schema)
- valid = Config()
- valid.read_string("""\
- [test]
- test_option: 5
- """)
- invalid = Config()
- invalid.read_string("""\
- [test]
- test_option: xyz
+ cfg = Config()
+ cfg.read_string("""\
+ [other_section]
+ some_option: something else
""")
- validator.validate(valid)
- self.assertRaises(ValueError, validator.validate, invalid)
+ self.assertRaises(ValueError, validator.validate, cfg)
- def test_callable(self):
+ def test_additional_section(self):
schema = """\
[test]
- test_option: lazr.config.as_boolean
+ test_option: something
"""
validator = ConfigValidator(schema)
- valid = Config()
- valid.read_string("""\
- [test]
- test_option: yes
- """)
- invalid = Config()
- invalid.read_string("""\
+ cfg = Config()
+ cfg.read_string("""\
[test]
- test_option: xyz
+ test_option: something
+ [other_section]
+ some_option: something else
""")
- validator.validate(valid)
- self.assertRaises(ValueError, validator.validate, invalid)
+ self.assertRaises(ValueError, validator.validate, cfg)
- def test_regex(self):
+ def test_missing_option(self):
schema = """\
[test]
- test_option: 29*4
+ test_option: something
"""
validator = ConfigValidator(schema)
- valid = Config()
- valid.read_string("""\
- [test]
- test_option: 2999999994
- """)
- invalid = Config()
- invalid.read_string("""\
+ cfg = Config()
+ cfg.read_string("""\
[test]
- test_option: xyz
""")
- validator.validate(valid)
- self.assertRaises(ValueError, validator.validate, invalid)
+ self.assertRaises(ValueError, validator.validate, cfg)
- def test_none(self):
+ def test_additional_option(self):
schema = """\
[test]
- test_option:
+ test_option: something
"""
validator = ConfigValidator(schema)
cfg = Config()
cfg.read_string("""\
[test]
test_option: something
+ other_option: something else
""")
self.assertRaises(ValueError, validator.validate, cfg)