mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-23 15:40:01 -06:00
42: plugable.Plugin.__init__() now takes the plugable.API instance as its single argument
This commit is contained in:
parent
a0f480a414
commit
74f5719078
@ -49,6 +49,16 @@ class Plugin(object):
|
|||||||
Base class for all plugins.
|
Base class for all plugins.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def __init__(self, api):
|
||||||
|
self.__api = api
|
||||||
|
|
||||||
|
def __get_api(self):
|
||||||
|
"""
|
||||||
|
Returns the plugable.API object this plugin has been instatiated in.
|
||||||
|
"""
|
||||||
|
return self.__api
|
||||||
|
api = property(__get_api)
|
||||||
|
|
||||||
def __get_name(self):
|
def __get_name(self):
|
||||||
"""
|
"""
|
||||||
Returns the class name of this instance.
|
Returns the class name of this instance.
|
||||||
@ -132,6 +142,8 @@ class NameSpace(ReadOnly):
|
|||||||
|
|
||||||
def __init__(self, items):
|
def __init__(self, items):
|
||||||
"""
|
"""
|
||||||
|
`items` should be an iterable providing the members of this
|
||||||
|
NameSpace.
|
||||||
"""
|
"""
|
||||||
object.__setattr__(self, '_NameSpace__items', tuple(items))
|
object.__setattr__(self, '_NameSpace__items', tuple(items))
|
||||||
|
|
||||||
@ -182,7 +194,6 @@ class NameSpace(ReadOnly):
|
|||||||
raise KeyError('NameSpace has no item for key %r' % key)
|
raise KeyError('NameSpace has no item for key %r' % key)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Registrar(object):
|
class Registrar(object):
|
||||||
def __init__(self, *allowed):
|
def __init__(self, *allowed):
|
||||||
"""
|
"""
|
||||||
@ -265,3 +276,9 @@ class Registrar(object):
|
|||||||
"""
|
"""
|
||||||
for base in self.__allowed:
|
for base in self.__allowed:
|
||||||
yield (base, self.__d[base.__name__].values())
|
yield (base, self.__d[base.__name__].values())
|
||||||
|
|
||||||
|
|
||||||
|
class API(ReadOnly):
|
||||||
|
def __init__(self, registrar):
|
||||||
|
for (base, plugins) in registrar:
|
||||||
|
pass
|
||||||
|
@ -42,14 +42,17 @@ def test_from_cli():
|
|||||||
|
|
||||||
|
|
||||||
def test_Plugin():
|
def test_Plugin():
|
||||||
p = plugable.Plugin()
|
api = 'the api instance'
|
||||||
assert p.name == 'Plugin'
|
p = plugable.Plugin(api)
|
||||||
|
assert read_only(p, 'api') is api
|
||||||
|
assert read_only(p, 'name') == 'Plugin'
|
||||||
assert repr(p) == '%s.Plugin()' % plugable.__name__
|
assert repr(p) == '%s.Plugin()' % plugable.__name__
|
||||||
|
|
||||||
class some_plugin(plugable.Plugin):
|
class some_plugin(plugable.Plugin):
|
||||||
pass
|
pass
|
||||||
p = some_plugin()
|
p = some_plugin(api)
|
||||||
assert p.name == 'some_plugin'
|
assert read_only(p, 'api') is api
|
||||||
|
assert read_only(p, 'name') == 'some_plugin'
|
||||||
assert repr(p) == '%s.some_plugin()' % __name__
|
assert repr(p) == '%s.some_plugin()' % __name__
|
||||||
|
|
||||||
|
|
||||||
@ -302,3 +305,7 @@ def test_NameSpace():
|
|||||||
raises(KeyError, getitem, ns, cli)
|
raises(KeyError, getitem, ns, cli)
|
||||||
raises(AttributeError, getattr, ns, name)
|
raises(AttributeError, getattr, ns, name)
|
||||||
no_set(ns, name)
|
no_set(ns, name)
|
||||||
|
|
||||||
|
|
||||||
|
def test_API():
|
||||||
|
assert issubclass(plugable.API, plugable.ReadOnly)
|
||||||
|
Loading…
Reference in New Issue
Block a user