summaryrefslogtreecommitdiffstats
path: root/tests/test_ipalib/test_config.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-12-30 00:45:48 -0700
committerJason Gerard DeRose <jderose@redhat.com>2008-12-30 00:45:48 -0700
commit447c88a2bb9dd364f9c67a73bfce5000ac81d375 (patch)
tree85061cb22960e33a07ae3b29c6a9c6588163fe31 /tests/test_ipalib/test_config.py
parente14fc84dfccbb06f775bbd5d3de864c7b879453f (diff)
downloadfreeipa-447c88a2bb9dd364f9c67a73bfce5000ac81d375.tar.gz
freeipa-447c88a2bb9dd364f9c67a73bfce5000ac81d375.tar.xz
freeipa-447c88a2bb9dd364f9c67a73bfce5000ac81d375.zip
Started moving some core classes and functions from plugable.py to new base.py module
Diffstat (limited to 'tests/test_ipalib/test_config.py')
-rw-r--r--tests/test_ipalib/test_config.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/test_ipalib/test_config.py b/tests/test_ipalib/test_config.py
index 388994f43..7c53efe27 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.