mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
306: Added Plugin.set_api() method; added corresponding unit tests
This commit is contained in:
@@ -352,6 +352,14 @@ class Plugin(ReadOnly):
|
||||
assert api is not None, 'finalize() argument cannot be None'
|
||||
self.__api = api
|
||||
|
||||
def set_api(self, api):
|
||||
"""
|
||||
Set reference to `API` instance.
|
||||
"""
|
||||
assert self.__api is None, 'set_api() can only be called once'
|
||||
assert api is not None, 'set_api() argument cannot be None'
|
||||
self.__api = api
|
||||
|
||||
def __repr__(self):
|
||||
"""
|
||||
Returns a fully qualified module_name.class_name() representation that
|
||||
|
||||
@@ -387,6 +387,20 @@ class test_Plugin(ClassChecker):
|
||||
assert base.implemented_by(fail) is False
|
||||
assert base.implemented_by(fail()) is False
|
||||
|
||||
def test_set_api(self):
|
||||
"""
|
||||
Tests the `plugable.Plugin.set_api` method.
|
||||
"""
|
||||
api = 'the api instance'
|
||||
o = self.cls()
|
||||
assert o.api is None
|
||||
e = raises(AssertionError, o.set_api, None)
|
||||
assert str(e) == 'set_api() argument cannot be None'
|
||||
o.set_api(api)
|
||||
assert o.api is api
|
||||
e = raises(AssertionError, o.set_api, api)
|
||||
assert str(e) == 'set_api() can only be called once'
|
||||
|
||||
def test_finalize(self):
|
||||
"""
|
||||
Tests the `plugable.Plugin.finalize` method.
|
||||
|
||||
Reference in New Issue
Block a user