summaryrefslogtreecommitdiffstats
path: root/ipalib/tests/test_public.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-08-11 22:12:23 +0000
committerJason Gerard DeRose <jderose@redhat.com>2008-08-11 22:12:23 +0000
commit902614a76297f6c3e3d329df6a6a5010765a37f5 (patch)
tree7209dbe5dc640b7b8439132d7d76daefd3f91396 /ipalib/tests/test_public.py
parentafdbc42b2e721012daf7020430353c0686fcc5c3 (diff)
downloadfreeipa.git-902614a76297f6c3e3d329df6a6a5010765a37f5.tar.gz
freeipa.git-902614a76297f6c3e3d329df6a6a5010765a37f5.tar.xz
freeipa.git-902614a76297f6c3e3d329df6a6a5010765a37f5.zip
113: Fixed regex used in attr.__init__(); added unit tests for mthd.get_options()
Diffstat (limited to 'ipalib/tests/test_public.py')
-rw-r--r--ipalib/tests/test_public.py42
1 files changed, 41 insertions, 1 deletions
diff --git a/ipalib/tests/test_public.py b/ipalib/tests/test_public.py
index 132cd1cc..4a445140 100644
--- a/ipalib/tests/test_public.py
+++ b/ipalib/tests/test_public.py
@@ -299,6 +299,10 @@ def test_attr():
assert read_only(i, 'api') is api
assert read_only(i, 'obj') == 'the user obj'
+ class example_prop0(cls):
+ pass
+ o = example_prop0()
+
class test_mthd(ClassChecker):
"""
@@ -310,6 +314,43 @@ class test_mthd(ClassChecker):
assert self.cls.__bases__ == (public.attr, public.cmd)
assert self.cls.implements(public.cmd)
+ def get_subcls(self):
+ class option0(public.option):
+ pass
+ class option1(public.option):
+ pass
+ class example_prop0(public.prop):
+ pass
+ class example_prop1(public.prop):
+ pass
+ class example_obj(object):
+ __prop = None
+ def __get_prop(self):
+ if self.__prop is None:
+ self.__prop = (
+ plugable.Proxy(public.prop, example_prop0(), 'attr_name'),
+ plugable.Proxy(public.prop, example_prop1(), 'attr_name'),
+ )
+ return self.__prop
+ prop = property(__get_prop)
+ class noun_verb(self.cls):
+ option_classes = (option0, option1)
+ obj = example_obj()
+ return noun_verb
+
+ def test_get_options(self):
+ """
+ Tests the `get_options` method.
+ """
+ sub = self.subcls()
+ names = ('option0', 'option1', 'prop0', 'prop1')
+ proxies = tuple(sub.get_options())
+ assert len(proxies) == 4
+ for (i, proxy) in enumerate(proxies):
+ assert proxy.name == names[i]
+ assert isinstance(proxy, plugable.Proxy)
+ assert proxy.implements(public.option)
+
class test_prop(ClassChecker):
_cls = public.prop
@@ -319,7 +360,6 @@ class test_prop(ClassChecker):
assert self.cls.implements(public.option)
-
def test_PublicAPI():
cls = public.PublicAPI
assert issubclass(cls, plugable.API)