summaryrefslogtreecommitdiffstats
path: root/src/nbblib/test-plugins.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/nbblib/test-plugins.py')
-rw-r--r--src/nbblib/test-plugins.py85
1 files changed, 83 insertions, 2 deletions
diff --git a/src/nbblib/test-plugins.py b/src/nbblib/test-plugins.py
index 1187062..aee2d23 100644
--- a/src/nbblib/test-plugins.py
+++ b/src/nbblib/test-plugins.py
@@ -14,6 +14,87 @@ if True:
logging.error("xxx error")
-import plugins
-plugins.selftest()
+from plugins import *
+
+# Not for __all__
+def selftest():
+
+ class PluginNoMatchA(PluginNoMatch):
+ pass
+ class AmbigousPluginDetectionA(AmbigousPluginDetection):
+ pass
+
+
+ class TestDetectPluginA(GenericDetectPlugin):
+ __metaclass__ = GenericPluginMeta
+ no_match_exception = PluginNoMatchA
+ ambigous_match_exception = AmbigousPluginDetectionA
+ @classmethod
+ def validate(cls, obj, context, *args, **kwargs):
+ logging.debug("Aval")
+ return False
+
+
+ class TestDetectPluginB(GenericDetectPlugin):
+ __metaclass__ = GenericPluginMeta
+
+
+ class TestDetectPluginC(GenericDetectPlugin):
+ __metaclass__ = GenericPluginMeta
+ @classmethod
+ def validate(cls, obj, context, *args, **kwargs):
+ logging.debug("Cval")
+ return False
+
+
+ class TestDetectPluginA1(TestDetectPluginA):
+ name = "A1"
+ class TestDetectPluginA2(TestDetectPluginA):
+ name = "A2"
+ class TestDetectPluginA3(TestDetectPluginA):
+ name = "A3"
+
+ class TestDetectPluginB1(TestDetectPluginB):
+ name = "B1"
+ class TestDetectPluginB2(TestDetectPluginB):
+ name = "B2"
+ class TestDetectPluginB3(TestDetectPluginB):
+ name = "B3"
+
+ class TestDetectPluginC1(TestDetectPluginC):
+ name = "C1"
+ class TestDetectPluginC2(TestDetectPluginC):
+ name = "C2"
+ class TestDetectPluginC3(TestDetectPluginC):
+ name = "C3"
+ @classmethod
+ def validate(cls, obj, context, *args, **kwargs):
+ logging.debug("C3val")
+ return True
+
+ ctx = None
+
+ print "GenericPluginMeta", dir(GenericPluginMeta)
+ print "GenericDetectPlugin", dir(GenericDetectPlugin)
+ print "TestDetectPluginA", dir(TestDetectPluginA)
+ print "TestDetectPluginA", dir(TestDetectPluginA)
+ print "TestDetectPluginB", dir(TestDetectPluginB)
+ print "TestDetectPluginC", dir(TestDetectPluginC)
+
+ try:
+ a = TestDetectPluginA.detect(ctx)
+ except:
+ logging.error("aaaa", exc_info=True)
+
+ try:
+ b = TestDetectPluginB.detect(ctx)
+ except:
+ logging.error("bbbb", exc_info=True)
+
+ try:
+ c = TestDetectPluginC.detect(ctx)
+ except:
+ logging.error("cccc", exc_info=True)
+
+selftest()