diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-02 19:29:00 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-02 19:29:00 +0000 |
commit | adf8b9b2d8ac4d5a73ed453fb1c05c28b3efc7b3 (patch) | |
tree | a18897a6680c8b3a6fc5ef3d8ea79ece6f48724b | |
parent | 85f7a08e5d11b3d09b6c36b7a683f39846f8821e (diff) | |
download | freeipa-adf8b9b2d8ac4d5a73ed453fb1c05c28b3efc7b3.tar.gz freeipa-adf8b9b2d8ac4d5a73ed453fb1c05c28b3efc7b3.tar.xz freeipa-adf8b9b2d8ac4d5a73ed453fb1c05c28b3efc7b3.zip |
232: Added Option2.get_values() method; added corresponding unit tests
-rw-r--r-- | ipalib/public.py | 5 | ||||
-rw-r--r-- | ipalib/tests/test_public.py | 12 |
2 files changed, 17 insertions, 0 deletions
diff --git a/ipalib/public.py b/ipalib/public.py index cf95af7cd..c01a88d91 100644 --- a/ipalib/public.py +++ b/ipalib/public.py @@ -152,6 +152,11 @@ class Option2(plugable.ReadOnly): return self.convert(default) return self.convert(self.default) + def get_values(self): + if self.type.name in ('Enum', 'CallbackEnum'): + return self.type.values + return tuple() + class Option(plugable.Plugin): """ diff --git a/ipalib/tests/test_public.py b/ipalib/tests/test_public.py index 56da573ad..be1b9158b 100644 --- a/ipalib/tests/test_public.py +++ b/ipalib/tests/test_public.py @@ -291,6 +291,18 @@ class test_Option2(ClassChecker): assert o.get_default() == (default,) assert o.get_default(first='John', last='Doe') == ('Hello, John Doe!',) + def test_get_default(self): + """ + Tests the `public.Option2.get_values` method. + """ + name = 'status' + doc = 'Account status' + values = (u'Active', u'Inactive') + o = self.cls(name, doc, ipa_types.Unicode()) + assert o.get_values() == tuple() + o = self.cls(name, doc, ipa_types.Enum(*values)) + assert o.get_values() == values + class test_Option(ClassChecker): """ |