forked from p15670423/monkey
Really basic test harness for plugins
This commit is contained in:
parent
4e7269b4df
commit
87cedacb7d
|
@ -0,0 +1,21 @@
|
|||
# test - should run true
|
||||
# test - should run false
|
||||
# test - invalid parent class but should run true
|
||||
# test - imported from other file, should not collect
|
||||
# test - failed to instance
|
||||
|
||||
|
||||
from unittest import TestCase
|
||||
import infection_monkey.utils.plugins.plugins_testcases
|
||||
from infection_monkey.utils.plugins.load_plugins import get_instances
|
||||
from infection_monkey.utils.plugins.plugin import Plugin
|
||||
|
||||
|
||||
class PluginTester(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test_plugins(self):
|
||||
res = get_instances(infection_monkey.utils.plugins.plugins_testcases.__package__,infection_monkey.utils.plugins.plugins_testcases.__file__,Plugin)
|
||||
self.assertEqual(len(res), 1)
|
|
@ -0,0 +1 @@
|
|||
from infection_monkey.utils.plugins.plugins_testcases.plugin_test_run import PluginShouldRun
|
|
@ -0,0 +1,11 @@
|
|||
from infection_monkey.utils.plugins.plugin import Plugin
|
||||
|
||||
|
||||
class PluginShouldRun(Plugin):
|
||||
|
||||
def __init__(self):
|
||||
raise ValueError("Some Error")
|
||||
|
||||
@staticmethod
|
||||
def should_run(class_name: str) -> bool:
|
||||
return True
|
|
@ -0,0 +1,4 @@
|
|||
class PluginNoInherit:
|
||||
@staticmethod
|
||||
def should_run(class_name: str) -> bool:
|
||||
return True
|
|
@ -0,0 +1,7 @@
|
|||
from infection_monkey.utils.plugins.plugin import Plugin
|
||||
|
||||
|
||||
class PluginDontRun(Plugin):
|
||||
@staticmethod
|
||||
def should_run(class_name: str) -> bool:
|
||||
return False
|
|
@ -0,0 +1,7 @@
|
|||
from infection_monkey.utils.plugins.plugin import Plugin
|
||||
|
||||
|
||||
class PluginShouldRun(Plugin):
|
||||
@staticmethod
|
||||
def should_run(class_name: str) -> bool:
|
||||
return True
|
Loading…
Reference in New Issue