summaryrefslogtreecommitdiffstats
path: root/tests/test_ipalib/test_config.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-12-22 21:02:43 -0700
committerJason Gerard DeRose <jderose@redhat.com>2008-12-22 21:02:43 -0700
commit01cae56e0a19876cf6a614469c0c5e6fb73170e6 (patch)
tree8bfcfaebea1f23c7de8217520c96e2c3b76268eb /tests/test_ipalib/test_config.py
parent6b055b435f93bf9b63ee9b3b2fdd6f082dacc07b (diff)
downloadfreeipa-01cae56e0a19876cf6a614469c0c5e6fb73170e6.tar.gz
freeipa-01cae56e0a19876cf6a614469c0c5e6fb73170e6.tar.xz
freeipa-01cae56e0a19876cf6a614469c0c5e6fb73170e6.zip
Some more reorganization in Env and added class docstring to Env with lots of examples
Diffstat (limited to 'tests/test_ipalib/test_config.py')
-rw-r--r--tests/test_ipalib/test_config.py64
1 files changed, 31 insertions, 33 deletions
diff --git a/tests/test_ipalib/test_config.py b/tests/test_ipalib/test_config.py
index c1a5faaa0..740ef6cf6 100644
--- a/tests/test_ipalib/test_config.py
+++ b/tests/test_ipalib/test_config.py
@@ -28,7 +28,7 @@ import sys
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, LOCK_ERROR
+from ipalib.constants import TYPE_ERROR, OVERRIDE_ERROR, SET_ERROR, DEL_ERROR
from ipalib import config, constants
@@ -177,7 +177,7 @@ class test_Env(ClassChecker):
o.__lock__()
for (name, raw, value) in good_vars:
e = raises(AttributeError, setattr, o, name, raw)
- assert str(e) == LOCK_ERROR % ('Env', name, raw)
+ assert str(e) == SET_ERROR % ('Env', name, raw)
def test_setitem(self):
"""
@@ -201,7 +201,35 @@ class test_Env(ClassChecker):
o.__lock__()
for (key, raw, value) in good_vars:
e = raises(AttributeError, o.__setitem__, key, raw)
- assert str(e) == LOCK_ERROR % ('Env', key, raw)
+ assert str(e) == SET_ERROR % ('Env', key, raw)
+
+ def test_getitem(self):
+ """
+ Test the `ipalib.config.Env.__getitem__` method.
+ """
+ o = self.cls()
+ value = 'some value'
+ o.key = value
+ assert o.key is value
+ assert o['key'] is value
+ for name in ('one', 'two'):
+ e = raises(KeyError, getitem, o, name)
+ assert str(e) == repr(name)
+
+ def test_delattr(self):
+ """
+ Test the `ipalib.config.Env.__delattr__` method.
+
+ This also tests that ``__delitem__`` is not implemented.
+ """
+ o = self.cls()
+ o.one = 1
+ assert o.one == 1
+ for key in ('one', 'two'):
+ e = raises(AttributeError, delattr, o, key)
+ assert str(e) == DEL_ERROR % ('Env', key)
+ e = raises(AttributeError, delitem, o, key)
+ assert str(e) == '__delitem__'
def bootstrap(self, **overrides):
(o, home) = self.new()
@@ -445,36 +473,6 @@ class test_Env(ClassChecker):
e = raises(StandardError, o.__lock__)
assert str(e) == 'Env.__lock__() already called'
- def test_getitem(self):
- """
- Test the `ipalib.config.Env.__getitem__` method.
- """
- o = self.cls()
- value = 'some value'
- o.key = value
- assert o.key is value
- assert o['key'] is value
- for name in ('one', 'two'):
- e = raises(KeyError, getitem, o, name)
- assert str(e) == repr(name)
-
-
-
- def test_delattr(self):
- """
- Test the `ipalib.config.Env.__delattr__` method.
-
- This also tests that ``__delitem__`` is not implemented.
- """
- o = self.cls()
- o.one = 1
- assert o.one == 1
- for key in ('one', 'two'):
- e = raises(AttributeError, delattr, o, key)
- assert str(e) == 'cannot del Env.%s' % key
- e = raises(AttributeError, delitem, o, key)
- assert str(e) == '__delitem__'
-
def test_contains(self):
"""
Test the `ipalib.config.Env.__contains__` method.