diff --git a/ipalib/public.py b/ipalib/public.py index 48e19ff40..95ba75549 100644 --- a/ipalib/public.py +++ b/ipalib/public.py @@ -136,7 +136,6 @@ class cmd(plugable.Plugin): '__call__', 'get_doc', 'options', - )) __options = None option_classes = tuple() @@ -248,6 +247,10 @@ class obj(plugable.Plugin): class attr(plugable.Plugin): + __public__ = frozenset(( + 'obj', + 'obj_name', + )) __obj = None def __init__(self): @@ -278,17 +281,18 @@ class attr(plugable.Plugin): class mthd(attr, cmd): - __public__ = frozenset(( - 'obj', - 'obj_name', - )) + __public__ = attr.__public__.union(cmd.__public__) + + def get_options(self): + for proxy in cmd.get_options(self): + yield proxy + if self.obj is not None and self.obj.prop is not None: + for proxy in self.obj.prop: + yield proxy -class prop(attr): - __public__ = frozenset(( - 'obj', - 'obj_name', - )) +class prop(attr, option): + __public__ = attr.__public__.union(option.__public__) def get_doc(self, _): return _('prop doc') diff --git a/ipalib/tests/test_public.py b/ipalib/tests/test_public.py index d6f3dbbe1..132cd1ccd 100644 --- a/ipalib/tests/test_public.py +++ b/ipalib/tests/test_public.py @@ -300,15 +300,24 @@ def test_attr(): assert read_only(i, 'obj') == 'the user obj' -def test_mthd(): - cls = public.mthd - assert issubclass(cls, public.attr) - assert issubclass(cls, public.cmd) +class test_mthd(ClassChecker): + """ + Tests the `mthd` class. + """ + _cls = public.mthd + + def test_class(self): + assert self.cls.__bases__ == (public.attr, public.cmd) + assert self.cls.implements(public.cmd) -def test_prop(): - cls = public.prop - assert issubclass(cls, public.attr) +class test_prop(ClassChecker): + _cls = public.prop + + def test_class(self): + assert self.cls.__bases__ == (public.attr, public.option) + assert self.cls.implements(public.option) + def test_PublicAPI():