summaryrefslogtreecommitdiffstats
path: root/ipalib/tests/test_public.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-08-11 17:37:33 +0000
committerJason Gerard DeRose <jderose@redhat.com>2008-08-11 17:37:33 +0000
commitfd6c215d596912493fa582079a7ec6de45466446 (patch)
treeaefd4627987f8ff512a84b65c7b4457d5dfce9d5 /ipalib/tests/test_public.py
parent8aee8e060c8d155ea0798cb677e784a0a72fa7ab (diff)
downloadfreeipa.git-fd6c215d596912493fa582079a7ec6de45466446.tar.gz
freeipa.git-fd6c215d596912493fa582079a7ec6de45466446.tar.xz
freeipa.git-fd6c215d596912493fa582079a7ec6de45466446.zip
107: Some cleanup in cmd; added unit tests for cmd.default() method
Diffstat (limited to 'ipalib/tests/test_public.py')
-rw-r--r--ipalib/tests/test_public.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/ipalib/tests/test_public.py b/ipalib/tests/test_public.py
index 7e98b735..8f0ac963 100644
--- a/ipalib/tests/test_public.py
+++ b/ipalib/tests/test_public.py
@@ -167,6 +167,13 @@ class test_cmd(ClassChecker):
class my_option(public.option):
def normalize(self, value):
return super(my_option, self).normalize(value).lower()
+ @public.rule
+ def my_rule(self, value):
+ if value != self.name:
+ return 'must equal %s' % name
+ def default(self, **kw):
+ return kw['default_from']
+
class option0(my_option):
pass
class option1(my_option):
@@ -221,6 +228,28 @@ class test_cmd(ClassChecker):
sub = self.subcls()
assert sub.normalize(**kw) == norm
+ def test_default(self):
+ """
+ Tests the `default` method.
+ """
+ assert 'default' in self.cls.__public__ # Public
+ no_fill = dict(
+ option0='value0',
+ option1='value1',
+ whatever='hello world',
+ )
+ fill = dict(
+ default_from='the default',
+ )
+ filled = dict(
+ option0='the default',
+ option1='the default',
+ default_from='the default',
+ )
+ sub = self.subcls()
+ assert sub.default(**no_fill) == no_fill
+ assert sub.default(**fill) == filled
+
def test_obj():
cls = public.obj