summaryrefslogtreecommitdiffstats
path: root/ipatests/test_ipalib
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2016-03-07 08:47:27 +0100
committerJan Cholasta <jcholast@redhat.com>2016-05-25 16:06:26 +0200
commita30bc8a351b983725c082e603f311e17a6d0178e (patch)
tree8237c98e499b8d32658f2af8f5d6cec1a98882d5 /ipatests/test_ipalib
parent88c0b66abc69ea5ab4a5beb72a1de2c5a74fd0c6 (diff)
downloadfreeipa-a30bc8a351b983725c082e603f311e17a6d0178e.tar.gz
freeipa-a30bc8a351b983725c082e603f311e17a6d0178e.tar.xz
freeipa-a30bc8a351b983725c082e603f311e17a6d0178e.zip
plugable: switch API to Registry-based plugin discovery
Merge Registrar into Registry. Use the Registry instance of each plugin module to discover plugins in the module instead of the global Registrar instance. This removes the side-effect of all plugins in a module being re-registered every time the module is imported. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
Diffstat (limited to 'ipatests/test_ipalib')
-rw-r--r--ipatests/test_ipalib/test_plugable.py36
1 files changed, 13 insertions, 23 deletions
diff --git a/ipatests/test_ipalib/test_plugable.py b/ipatests/test_ipalib/test_plugable.py
index 0434d7970..a618550e7 100644
--- a/ipatests/test_ipalib/test_plugable.py
+++ b/ipatests/test_ipalib/test_plugable.py
@@ -98,9 +98,9 @@ class test_Plugin(ClassChecker):
assert o.__islocked__()
-def test_Registrar():
+def test_Registry():
"""
- Test the `ipalib.plugable.Registrar` class
+ Test the `ipalib.plugable.Registry` class
"""
class Base1(object):
pass
@@ -115,59 +115,49 @@ def test_Registrar():
class plugin3(Base3):
pass
- # Test creation of Registrar:
- r = plugable.Registrar()
+ # Test creation of Registry:
+ r = plugable.Registry()
# Check that TypeError is raised trying to register something that isn't
# a class:
p = plugin1()
- e = raises(TypeError, r, p)
+ e = raises(TypeError, r(), p)
assert str(e) == 'plugin must be a class; got %r' % p
# Check that registration works
- r(plugin1)
- assert len(r) == 1
- assert plugin1 in r
- assert r[plugin1] == dict(override=False)
+ r()(plugin1)
# Check that DuplicateError is raised trying to register exact class
# again:
- e = raises(errors.PluginDuplicateError, r, plugin1)
+ e = raises(errors.PluginDuplicateError, r(), plugin1)
assert e.plugin is plugin1
# Check that overriding works
- orig1 = plugin1
class base1_extended(Base1):
pass
class plugin1(base1_extended): # pylint: disable=function-redefined
pass
- r(plugin1, override=True)
- assert len(r) == 2
- assert plugin1 in r
- assert r[plugin1] == dict(override=True)
+ r(override=True)(plugin1)
# Test that another plugin can be registered:
- r(plugin2)
- assert len(r) == 3
- assert plugin2 in r
- assert r[plugin2] == dict(override=False)
+ r()(plugin2)
# Setup to test more registration:
class plugin1a(Base1):
pass
- r(plugin1a)
+ r()(plugin1a)
class plugin1b(Base1):
pass
- r(plugin1b)
+ r()(plugin1b)
class plugin2a(Base2):
pass
- r(plugin2a)
+ r()(plugin2a)
class plugin2b(Base2):
pass
- r(plugin2b)
+ r()(plugin2b)
class test_API(ClassChecker):