diff options
Diffstat (limited to 'tests/test_ipalib/test_config.py')
-rw-r--r-- | tests/test_ipalib/test_config.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/test_ipalib/test_config.py b/tests/test_ipalib/test_config.py index 388994f4..7c53efe2 100644 --- a/tests/test_ipalib/test_config.py +++ b/tests/test_ipalib/test_config.py @@ -21,7 +21,6 @@ Test the `ipalib.config` module. """ -import types import os from os import path import sys @@ -29,6 +28,7 @@ from tests.util import raises, setitem, delitem, ClassChecker from tests.util import getitem, setitem, delitem from tests.util import TempDir, TempHome from ipalib.constants import TYPE_ERROR, OVERRIDE_ERROR, SET_ERROR, DEL_ERROR +from ipalib.constants import NAME_REGEX, NAME_ERROR from ipalib import config, constants @@ -56,6 +56,13 @@ good_vars = ( ) +bad_names = ( + ('CamelCase', 'value'), + ('_leading_underscore', 'value'), + ('trailing_underscore_', 'value'), +) + + # Random base64-encoded data to simulate a misbehaving config file. config_bad = """ /9j/4AAQSkZJRgABAQEAlgCWAAD//gAIT2xpdmVy/9sAQwAQCwwODAoQDg0OEhEQExgoGhgWFhgx @@ -179,6 +186,12 @@ class test_Env(ClassChecker): e = raises(AttributeError, setattr, o, name, raw) assert str(e) == SET_ERROR % ('Env', name, raw) + # Test that name is tested with check_name(): + o = self.cls() + for (name, value) in bad_names: + e = raises(ValueError, setattr, o, name, value) + assert str(e) == NAME_ERROR % (NAME_REGEX, name) + def test_setitem(self): """ Test the `ipalib.config.Env.__setitem__` method. @@ -203,6 +216,12 @@ class test_Env(ClassChecker): e = raises(AttributeError, o.__setitem__, key, raw) assert str(e) == SET_ERROR % ('Env', key, raw) + # Test that name is tested with check_name(): + o = self.cls() + for (key, value) in bad_names: + e = raises(ValueError, o.__setitem__, key, value) + assert str(e) == NAME_ERROR % (NAME_REGEX, key) + def test_getitem(self): """ Test the `ipalib.config.Env.__getitem__` method. |