aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/conformance_tests.py5
-rw-r--r--tests/unittests/option_tests.py20
-rw-r--r--tests/unittests/plugin_tests.py37
3 files changed, 22 insertions, 40 deletions
diff --git a/tests/unittests/conformance_tests.py b/tests/unittests/conformance_tests.py
index 3a3f550f..5419f9d3 100644
--- a/tests/unittests/conformance_tests.py
+++ b/tests/unittests/conformance_tests.py
@@ -8,7 +8,7 @@
import unittest
-from sos.report.plugins import import_plugin
+from sos.report.plugins import import_plugin, PluginOpt
from sos.utilities import ImporterHelper
@@ -50,7 +50,8 @@ class PluginConformance(unittest.TestCase):
for plug in self.plug_classes:
self.assertIsInstance(plug.option_list, list)
for opt in plug.option_list:
- self.assertIsInstance(opt, tuple)
+ self.assertIsInstance(opt, PluginOpt)
+ self.assertFalse(opt.name == 'undefined')
def test_plugin_architectures_set_correctly(self):
for plug in self.plug_classes:
diff --git a/tests/unittests/option_tests.py b/tests/unittests/option_tests.py
index 58f54e94..4a9271ad 100644
--- a/tests/unittests/option_tests.py
+++ b/tests/unittests/option_tests.py
@@ -7,7 +7,7 @@
# See the LICENSE file in the source distribution for further information.
import unittest
-from sos.report.plugins import Plugin
+from sos.report.plugins import Plugin, PluginOpt
from sos.policies.distros import LinuxPolicy
from sos.policies.init_systems import InitSystem
@@ -21,6 +21,18 @@ class MockOptions(object):
skip_files = []
+class MockPlugin(Plugin):
+
+ option_list = [
+ PluginOpt('baz', default=False),
+ PluginOpt('empty', default=None),
+ PluginOpt('test_option', default='foobar')
+ ]
+
+ def __init__(self, commons):
+ super(MockPlugin, self).__init__(commons=commons)
+
+
class GlobalOptionTest(unittest.TestCase):
def setUp(self):
@@ -30,11 +42,7 @@ class GlobalOptionTest(unittest.TestCase):
'cmdlineopts': MockOptions(),
'devices': {}
}
- self.plugin = Plugin(self.commons)
- self.plugin.opt_names = ['baz', 'empty', 'test_option']
- self.plugin.opt_parms = [
- {'enabled': False}, {'enabled': None}, {'enabled': 'foobar'}
- ]
+ self.plugin = MockPlugin(self.commons)
def test_simple_lookup(self):
self.assertEquals(self.plugin.get_option('test_option'), 'foobar')
diff --git a/tests/unittests/plugin_tests.py b/tests/unittests/plugin_tests.py
index 8dc038cb..fcd24143 100644
--- a/tests/unittests/plugin_tests.py
+++ b/tests/unittests/plugin_tests.py
@@ -12,7 +12,7 @@ import shutil
from io import StringIO
-from sos.report.plugins import Plugin, regex_findall, _mangle_command
+from sos.report.plugins import Plugin, regex_findall, _mangle_command, PluginOpt
from sos.archive import TarFileArchive
from sos.policies.distros import LinuxPolicy
from sos.policies.init_systems import InitSystem
@@ -64,8 +64,10 @@ class MockArchive(TarFileArchive):
class MockPlugin(Plugin):
- option_list = [("opt", 'an option', 'fast', None),
- ("opt2", 'another option', 'fast', False)]
+ option_list = [
+ PluginOpt("opt", default=None, desc='an option', val_type=str),
+ PluginOpt("opt2", default=False, desc='another option')
+ ]
def setup(self):
pass
@@ -271,35 +273,6 @@ class PluginTests(unittest.TestCase):
})
self.assertEquals(p.get_option("opt2", True), False)
- def test_get_option_as_list_plugin_option(self):
- p = MockPlugin({
- 'sysroot': self.sysroot,
- 'policy': LinuxPolicy(init=InitSystem(), probe_runtime=False),
- 'cmdlineopts': MockOptions(),
- 'devices': {}
- })
- 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(init=InitSystem(), probe_runtime=False),
- 'cmdlineopts': MockOptions(),
- 'devices': {}
- })
- 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(init=InitSystem(), probe_runtime=False),
- 'cmdlineopts': MockOptions(),
- 'devices': {}
- })
- p.set_option("opt", "testing")
- self.assertEquals(p.get_option_as_list("opt"), ['testing'])
-
def test_copy_dir(self):
self.mp._do_copy_path("tests")
self.assertEquals(