summaryrefslogtreecommitdiffstats
path: root/tests/test_ipalib/test_config.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2009-01-06 18:21:46 -0700
committerJason Gerard DeRose <jderose@redhat.com>2009-01-06 18:21:46 -0700
commit166b3ca80c2ed651eb2a5c20bcda5b51ed9e5e2e (patch)
tree33f59d82e949a8d01de98fe244506deaed03ebd5 /tests/test_ipalib/test_config.py
parent9e430755a5cbcd27e2312d5bee1061704a7215bf (diff)
downloadfreeipa-166b3ca80c2ed651eb2a5c20bcda5b51ed9e5e2e.tar.gz
freeipa-166b3ca80c2ed651eb2a5c20bcda5b51ed9e5e2e.tar.xz
freeipa-166b3ca80c2ed651eb2a5c20bcda5b51ed9e5e2e.zip
Added unit test for Env.__islocked__(); unit test for Env.__lock__() now also tests with base.lock() function
Diffstat (limited to 'tests/test_ipalib/test_config.py')
-rw-r--r--tests/test_ipalib/test_config.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/tests/test_ipalib/test_config.py b/tests/test_ipalib/test_config.py
index ab8d90063..d3109f7b3 100644
--- a/tests/test_ipalib/test_config.py
+++ b/tests/test_ipalib/test_config.py
@@ -30,7 +30,7 @@ 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
+from ipalib import config, constants, base
# Valid environment variables in (key, raw, value) tuples:
@@ -162,12 +162,31 @@ class test_Env(ClassChecker):
Test the `ipalib.config.Env.__lock__` method.
"""
o = self.cls()
- assert o._Env__locked is False
+ assert o.__islocked__() is False
o.__lock__()
- assert o._Env__locked is True
+ assert o.__islocked__() is True
e = raises(StandardError, o.__lock__)
assert str(e) == 'Env.__lock__() already called'
+ # Also test with base.lock() function:
+ o = self.cls()
+ assert o.__islocked__() is False
+ assert base.lock(o) is o
+ assert o.__islocked__() is True
+ e = raises(AssertionError, base.lock, o)
+ assert str(e) == 'already locked: %r' % o
+
+ def test_islocked(self):
+ """
+ Test the `ipalib.config.Env.__islocked__` method.
+ """
+ o = self.cls()
+ assert o.__islocked__() is False
+ assert base.islocked(o) is False
+ o.__lock__()
+ assert o.__islocked__() is True
+ assert base.islocked(o) is True
+
def test_setattr(self):
"""
Test the `ipalib.config.Env.__setattr__` method.