diff options
Diffstat (limited to 'tests/plugin_tests.py')
-rw-r--r-- | tests/plugin_tests.py | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/tests/plugin_tests.py b/tests/plugin_tests.py index c03e313e..7d36957b 100644 --- a/tests/plugin_tests.py +++ b/tests/plugin_tests.py @@ -92,6 +92,7 @@ class EnablerPlugin(Plugin): class MockOptions(object): all_logs = False + dry_run = False log_size = 25 @@ -136,54 +137,58 @@ class PluginTests(unittest.TestCase): self.mp = MockPlugin({ 'cmdlineopts': MockOptions(), 'policy': LinuxPolicy(), - 'sysroot': self.sysroot + 'sysroot': self.sysroot, + 'cmdlineopts': MockOptions() }) self.mp.archive = MockArchive() def test_plugin_default_name(self): - p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy()}) + p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy(), + 'cmdlineopts': MockOptions()}) self.assertEquals(p.name(), "mockplugin") def test_plugin_set_name(self): - p = NamedMockPlugin({ - 'sysroot': self.sysroot, - 'policy': LinuxPolicy() - }) + p = NamedMockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy(), + 'cmdlineopts': MockOptions()}) self.assertEquals(p.name(), "testing") def test_plugin_no_descrip(self): - p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy()}) + p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy(), + 'cmdlineopts': MockOptions()}) self.assertEquals(p.get_description(), "<no description available>") def test_plugin_no_descrip(self): - p = NamedMockPlugin({ - 'sysroot': self.sysroot, - 'policy': LinuxPolicy() - }) + p = NamedMockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy(), + 'cmdlineopts': MockOptions()}) self.assertEquals(p.get_description(), "This plugin has a description.") def test_set_plugin_option(self): - p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy()}) + p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy(), + 'cmdlineopts': MockOptions()}) p.set_option("opt", "testing") self.assertEquals(p.get_option("opt"), "testing") def test_set_nonexistant_plugin_option(self): - p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy()}) + p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy(), + 'cmdlineopts': MockOptions()}) self.assertFalse(p.set_option("badopt", "testing")) def test_get_nonexistant_plugin_option(self): - p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy()}) + p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy(), + 'cmdlineopts': MockOptions()}) self.assertEquals(p.get_option("badopt"), 0) def test_get_unset_plugin_option(self): - p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy()}) + p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy(), + 'cmdlineopts': MockOptions()}) self.assertEquals(p.get_option("opt"), 0) def test_get_unset_plugin_option_with_default(self): # this shows that even when we pass in a default to get, # we'll get the option's default as set in the plugin # this might not be what we really want - p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy()}) + p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy(), + 'cmdlineopts': MockOptions()}) self.assertEquals(p.get_option("opt", True), True) def test_get_unset_plugin_option_with_default_not_none(self): @@ -191,20 +196,24 @@ class PluginTests(unittest.TestCase): # if the plugin default is not None # we'll get the option's default as set in the plugin # this might not be what we really want - p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy()}) + p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy(), + 'cmdlineopts': MockOptions()}) self.assertEquals(p.get_option("opt2", True), False) def test_get_option_as_list_plugin_option(self): - p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy()}) + p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy(), + 'cmdlineopts': MockOptions()}) p.set_option("opt", "one,two,three") self.assertEquals(p.get_option_as_list("opt"), ['one', 'two', 'three']) def test_get_option_as_list_plugin_option_default(self): - p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy()}) + p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy(), + 'cmdlineopts': MockOptions()}) self.assertEquals(p.get_option_as_list("opt", default=[]), []) def test_get_option_as_list_plugin_option_not_list(self): - p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy()}) + p = MockPlugin({'sysroot': self.sysroot, 'policy': LinuxPolicy(), + 'cmdlineopts': MockOptions()}) p.set_option("opt", "testing") self.assertEquals(p.get_option_as_list("opt"), ['testing']) @@ -236,7 +245,8 @@ class AddCopySpecTests(unittest.TestCase): self.mp = MockPlugin({ 'cmdlineopts': MockOptions(), 'policy': LinuxPolicy(), - 'sysroot': os.getcwd() + 'sysroot': os.getcwd(), + 'cmdlineopts': MockOptions() }) self.mp.archive = MockArchive() @@ -312,7 +322,8 @@ class CheckEnabledTests(unittest.TestCase): def setUp(self): self.mp = EnablerPlugin({ 'policy': sos.policies.load(), - 'sysroot': os.getcwd() + 'sysroot': os.getcwd(), + 'cmdlineopts': MockOptions() }) def test_checks_for_file(self): |