forked from p15670423/monkey
Rename test classes to match PEP.
Add test case with multiple classes in file. Remove setup in test runner.
This commit is contained in:
parent
dae5c789b5
commit
f118de3d21
|
@ -1,7 +1,7 @@
|
|||
from infection_monkey.utils.plugins.pluginTests.PluginTestClass import TestPlugin
|
||||
|
||||
|
||||
class badPluginInit(TestPlugin):
|
||||
class BadPluginInit(TestPlugin):
|
||||
|
||||
def __init__(self):
|
||||
raise Exception("TestException")
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
from infection_monkey.utils.plugins.pluginTests.PluginTestClass import TestPlugin
|
||||
|
||||
|
||||
class NoInheritance:
|
||||
pass
|
||||
|
||||
|
||||
class BadInit(TestPlugin):
|
||||
|
||||
def __init__(self):
|
||||
raise Exception("TestException")
|
||||
|
||||
|
||||
class ProperClass(TestPlugin):
|
||||
pass
|
|
@ -1,5 +1,5 @@
|
|||
from infection_monkey.utils.plugins.pluginTests.PluginTestClass import TestPlugin
|
||||
|
||||
|
||||
class pluginWorking(TestPlugin):
|
||||
class PluginWorking(TestPlugin):
|
||||
pass
|
||||
|
|
|
@ -1,18 +1,23 @@
|
|||
from unittest import TestCase
|
||||
|
||||
from infection_monkey.utils.plugins.pluginTests.PluginWorking import pluginWorking
|
||||
from infection_monkey.utils.plugins.pluginTests.ComboFile import BadInit, ProperClass
|
||||
from infection_monkey.utils.plugins.pluginTests.PluginWorking import PluginWorking
|
||||
from infection_monkey.utils.plugins.pluginTests.BadImport import SomeDummyPlugin
|
||||
from infection_monkey.utils.plugins.pluginTests.BadInit import badPluginInit
|
||||
from infection_monkey.utils.plugins.pluginTests.BadInit import BadPluginInit
|
||||
from infection_monkey.utils.plugins.pluginTests.PluginTestClass import TestPlugin
|
||||
|
||||
|
||||
class PluginTester(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
def test_combo_file(self):
|
||||
TestPlugin.classes_to_load = [BadInit.__name__, ProperClass.__name__]
|
||||
to_init = TestPlugin.get_classes()
|
||||
self.assertEqual(len(to_init), 2)
|
||||
objects = TestPlugin.get_instances()
|
||||
self.assertEqual(len(objects), 1)
|
||||
|
||||
def test_bad_init(self):
|
||||
TestPlugin.classes_to_load = [badPluginInit.__name__]
|
||||
TestPlugin.classes_to_load = [BadPluginInit.__name__]
|
||||
to_init = TestPlugin.get_classes()
|
||||
self.assertEqual(len(to_init), 1)
|
||||
objects = TestPlugin.get_instances()
|
||||
|
@ -24,7 +29,7 @@ class PluginTester(TestCase):
|
|||
self.assertEqual(len(to_init), 0)
|
||||
|
||||
def test_flow(self):
|
||||
TestPlugin.classes_to_load = [pluginWorking.__name__]
|
||||
TestPlugin.classes_to_load = [PluginWorking.__name__]
|
||||
to_init = TestPlugin.get_classes()
|
||||
self.assertEqual(len(to_init), 1)
|
||||
objects = TestPlugin.get_instances()
|
||||
|
|
Loading…
Reference in New Issue