diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-11 16:29:37 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-11 16:29:37 +0000 |
commit | 8aee8e060c8d155ea0798cb677e784a0a72fa7ab (patch) | |
tree | ab33e1c94f67caa28c76908ad4b1c31bdac08661 /ipalib/tests/test_public.py | |
parent | 879133d28a2da2d675d72a3f4e178f5bc4c82594 (diff) | |
download | freeipa.git-8aee8e060c8d155ea0798cb677e784a0a72fa7ab.tar.gz freeipa.git-8aee8e060c8d155ea0798cb677e784a0a72fa7ab.tar.xz freeipa.git-8aee8e060c8d155ea0798cb677e784a0a72fa7ab.zip |
106: Fixed some typos in cmd.__get_options(); added unit tests for cmd.options and cmd.normalize()
Diffstat (limited to 'ipalib/tests/test_public.py')
-rw-r--r-- | ipalib/tests/test_public.py | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/ipalib/tests/test_public.py b/ipalib/tests/test_public.py index 91d1f724..7e98b735 100644 --- a/ipalib/tests/test_public.py +++ b/ipalib/tests/test_public.py @@ -164,9 +164,12 @@ class test_cmd(ClassChecker): _cls = public.cmd def get_subcls(self): - class option0(public.option): + class my_option(public.option): + def normalize(self, value): + return super(my_option, self).normalize(value).lower() + class option0(my_option): pass - class option1(public.option): + class option1(my_option): pass class example(self.cls): option_classes = (option0, option1) @@ -188,6 +191,36 @@ class test_cmd(ClassChecker): assert proxy.implements(public.option) assert i == 1 + def test_options(self): + """ + Tests the `options` property. + """ + assert 'options' in self.cls.__public__ # Public + sub = self.subcls() + options = sub.options + assert type(options) == plugable.NameSpace + assert len(options) == 2 + for name in ('option0', 'option1'): + assert name in options + proxy = options[name] + assert getattr(options, name) is proxy + assert isinstance(proxy, plugable.Proxy) + assert proxy.name == name + + def test_normalize(self): + """ + Tests the `normalize` method. + """ + assert 'normalize' in self.cls.__public__ # Public + kw = dict( + option0='OPTION0', + option1='OPTION1', + option2='option2', + ) + norm = dict((k, v.lower()) for (k, v) in kw.items()) + sub = self.subcls() + assert sub.normalize(**kw) == norm + def test_obj(): cls = public.obj |