summaryrefslogtreecommitdiffstats
path: root/ipalib/tests/test_public.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-08-22 20:07:17 +0000
committerJason Gerard DeRose <jderose@redhat.com>2008-08-22 20:07:17 +0000
commitcad924168eebbb3618205651f8c7a30bf00fe47d (patch)
treec63af18b0da146606de2da2bd04d592857b32e60 /ipalib/tests/test_public.py
parentb0ec8fe551bc5f454aa1babeab31a424fd8c9abe (diff)
downloadfreeipa.git-cad924168eebbb3618205651f8c7a30bf00fe47d.tar.gz
freeipa.git-cad924168eebbb3618205651f8c7a30bf00fe47d.tar.xz
freeipa.git-cad924168eebbb3618205651f8c7a30bf00fe47d.zip
183: Added public.DefaultFrom class; added corresponding unit tests
Diffstat (limited to 'ipalib/tests/test_public.py')
-rw-r--r--ipalib/tests/test_public.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/ipalib/tests/test_public.py b/ipalib/tests/test_public.py
index d053081d..1a496a16 100644
--- a/ipalib/tests/test_public.py
+++ b/ipalib/tests/test_public.py
@@ -63,6 +63,41 @@ def test_is_rule():
assert not is_rule(call(None))
+class test_DefaltFrom(ClassChecker):
+ """
+ Tests the `public.DefaltFrom` class.
+ """
+ _cls = public.DefaultFrom
+
+ def test_class(self):
+ assert self.cls.__bases__ == (plugable.ReadOnly,)
+
+ def test_init(self):
+ def callback(*args):
+ return args
+ keys = ('givenname', 'sn')
+ o = self.cls(callback, *keys)
+ assert read_only(o, 'callback') is callback
+ assert read_only(o, 'keys') == keys
+
+ def test_call(self):
+ def callback(givenname, sn):
+ return givenname[0] + sn[0]
+ keys = ('givenname', 'sn')
+ o = self.cls(callback, *keys)
+ kw = dict(
+ givenname='John',
+ sn='Public',
+ hello='world',
+ )
+ assert o(**kw) == 'JP'
+ assert o() is None
+ for key in ('givenname', 'sn'):
+ kw_copy = dict(kw)
+ del kw_copy[key]
+ assert o(**kw_copy) is None
+
+
class test_option(ClassChecker):
"""
Tests the `public.option` class.