mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
186: Renamed public.attr to Attribute; reworked public.Attribute unit tests using ClassChecker
This commit is contained in:
parent
5bf6a9eb09
commit
f60fa06ce2
@ -281,7 +281,7 @@ class obj(plugable.Plugin):
|
|||||||
yield proxy.__clone__('attr_name')
|
yield proxy.__clone__('attr_name')
|
||||||
|
|
||||||
|
|
||||||
class attr(plugable.Plugin):
|
class Attribute(plugable.Plugin):
|
||||||
__public__ = frozenset((
|
__public__ = frozenset((
|
||||||
'obj',
|
'obj',
|
||||||
'obj_name',
|
'obj_name',
|
||||||
@ -311,12 +311,12 @@ class attr(plugable.Plugin):
|
|||||||
obj = property(__get_obj)
|
obj = property(__get_obj)
|
||||||
|
|
||||||
def finalize(self, api):
|
def finalize(self, api):
|
||||||
super(attr, self).finalize(api)
|
super(Attribute, self).finalize(api)
|
||||||
self.__obj = api.obj[self.obj_name]
|
self.__obj = api.obj[self.obj_name]
|
||||||
|
|
||||||
|
|
||||||
class Method(attr, Command):
|
class Method(Attribute, Command):
|
||||||
__public__ = attr.__public__.union(Command.__public__)
|
__public__ = Attribute.__public__.union(Command.__public__)
|
||||||
|
|
||||||
def get_options(self):
|
def get_options(self):
|
||||||
for proxy in Command.get_options(self):
|
for proxy in Command.get_options(self):
|
||||||
@ -326,8 +326,8 @@ class Method(attr, Command):
|
|||||||
yield proxy
|
yield proxy
|
||||||
|
|
||||||
|
|
||||||
class Property(attr, option):
|
class Property(Attribute, option):
|
||||||
__public__ = attr.__public__.union(option.__public__)
|
__public__ = Attribute.__public__.union(option.__public__)
|
||||||
|
|
||||||
def get_doc(self, _):
|
def get_doc(self, _):
|
||||||
return _('Property doc')
|
return _('Property doc')
|
||||||
|
@ -327,27 +327,38 @@ def test_obj():
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_attr():
|
class test_Attribute(ClassChecker):
|
||||||
cls = public.attr
|
"""
|
||||||
assert issubclass(cls, plugable.Plugin)
|
Tests the `public.Attribute` class.
|
||||||
|
"""
|
||||||
|
_cls = public.Attribute
|
||||||
|
|
||||||
class api(object):
|
def test_class(self):
|
||||||
obj = dict(user='the user obj')
|
assert self.cls.__bases__ == (plugable.Plugin,)
|
||||||
|
assert type(self.cls.obj) is property
|
||||||
|
assert type(self.cls.obj_name) is property
|
||||||
|
assert type(self.cls.attr_name) is property
|
||||||
|
|
||||||
class user_add(cls):
|
def test_init(self):
|
||||||
pass
|
class user_add(self.cls):
|
||||||
|
pass
|
||||||
|
o = user_add()
|
||||||
|
assert read_only(o, 'obj') is None
|
||||||
|
assert read_only(o, 'obj_name') == 'user'
|
||||||
|
assert read_only(o, 'attr_name') == 'add'
|
||||||
|
|
||||||
i = user_add()
|
def test_finalize(self):
|
||||||
assert read_only(i, 'obj_name') == 'user'
|
user_obj = 'The user public.Object instance'
|
||||||
assert read_only(i, 'attr_name') == 'add'
|
class api(object):
|
||||||
assert read_only(i, 'obj') is None
|
obj = dict(user=user_obj)
|
||||||
i.finalize(api)
|
class user_add(self.cls):
|
||||||
assert read_only(i, 'api') is api
|
pass
|
||||||
assert read_only(i, 'obj') == 'the user obj'
|
o = user_add()
|
||||||
|
assert read_only(o, 'api') is None
|
||||||
class example_prop0(cls):
|
assert read_only(o, 'obj') is None
|
||||||
pass
|
o.finalize(api)
|
||||||
o = example_prop0()
|
assert read_only(o, 'api') is api
|
||||||
|
assert read_only(o, 'obj') is user_obj
|
||||||
|
|
||||||
|
|
||||||
class test_Method(ClassChecker):
|
class test_Method(ClassChecker):
|
||||||
@ -357,7 +368,7 @@ class test_Method(ClassChecker):
|
|||||||
_cls = public.Method
|
_cls = public.Method
|
||||||
|
|
||||||
def test_class(self):
|
def test_class(self):
|
||||||
assert self.cls.__bases__ == (public.attr, public.Command)
|
assert self.cls.__bases__ == (public.Attribute, public.Command)
|
||||||
assert self.cls.implements(public.Command)
|
assert self.cls.implements(public.Command)
|
||||||
|
|
||||||
def get_subcls(self):
|
def get_subcls(self):
|
||||||
@ -406,7 +417,7 @@ class test_prop(ClassChecker):
|
|||||||
_cls = public.Property
|
_cls = public.Property
|
||||||
|
|
||||||
def test_class(self):
|
def test_class(self):
|
||||||
assert self.cls.__bases__ == (public.attr, public.option)
|
assert self.cls.__bases__ == (public.Attribute, public.option)
|
||||||
assert self.cls.implements(public.option)
|
assert self.cls.implements(public.option)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user