diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-14 20:32:35 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-14 20:32:35 +0000 |
commit | d229a764749b37aded48ed6eec230df9105a62b0 (patch) | |
tree | f6a8e64718a8c4a48f707f1e6b711f79d3f94c4e /ipalib/tests | |
parent | 887667caa77bd0bd976e71e9b81b1062ae81f7bb (diff) | |
download | freeipa-d229a764749b37aded48ed6eec230df9105a62b0.tar.gz freeipa-d229a764749b37aded48ed6eec230df9105a62b0.tar.xz freeipa-d229a764749b37aded48ed6eec230df9105a62b0.zip |
165: Added unit tests for plugable.lock() function; replaced occurances of 'self.__lock__()' with 'lock(self)' in plugable.py
Diffstat (limited to 'ipalib/tests')
-rw-r--r-- | ipalib/tests/test_plugable.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/ipalib/tests/test_plugable.py b/ipalib/tests/test_plugable.py index b64cf305c..839451b57 100644 --- a/ipalib/tests/test_plugable.py +++ b/ipalib/tests/test_plugable.py @@ -88,6 +88,35 @@ class test_ReadOnly(ClassChecker): assert read_only(obj, 'an_attribute') == 'Hello world!' +def test_lock(): + """ + Tests the `plugable.lock` function. + """ + f = plugable.lock + + # Test on a ReadOnly instance: + o = plugable.ReadOnly() + assert not o.__islocked__() + assert f(o) is o + assert o.__islocked__() + + # Test on something not subclassed from ReadOnly: + class not_subclass(object): + def __lock__(self): + pass + def __islocked__(self): + return True + o = not_subclass() + raises(ValueError, f, o) + + # Test that it checks __islocked__(): + class subclass(plugable.ReadOnly): + def __islocked__(self): + return False + o = subclass() + raises(AssertionError, f, o) + + class test_Plugin(ClassChecker): """ Tests the `plugable.Plugin` class. |