From fd6c215d596912493fa582079a7ec6de45466446 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Mon, 11 Aug 2008 17:37:33 +0000 Subject: 107: Some cleanup in cmd; added unit tests for cmd.default() method --- ipalib/tests/test_public.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'ipalib/tests/test_public.py') 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 -- cgit