diff options
Diffstat (limited to 'tests')
-rw-r--r--[-rwxr-xr-x] | tests/archive_tests.py | 0 | ||||
-rw-r--r-- | tests/importer_tests.py | 13 | ||||
-rw-r--r-- | tests/policy_tests.py | 51 |
3 files changed, 64 insertions, 0 deletions
diff --git a/tests/archive_tests.py b/tests/archive_tests.py index 01c46395..01c46395 100755..100644 --- a/tests/archive_tests.py +++ b/tests/archive_tests.py diff --git a/tests/importer_tests.py b/tests/importer_tests.py new file mode 100644 index 00000000..91f82cc0 --- /dev/null +++ b/tests/importer_tests.py @@ -0,0 +1,13 @@ +import unittest + +from sos.utilities import ImporterHelper + +class ImporterHelperTests(unittest.TestCase): + + def test_runs(self): + h = ImporterHelper(unittest) + modules = h.get_modules() + self.assertTrue('main' in modules) + +if __name__ == "__main__": + unittest.main() diff --git a/tests/policy_tests.py b/tests/policy_tests.py new file mode 100644 index 00000000..2654c82c --- /dev/null +++ b/tests/policy_tests.py @@ -0,0 +1,51 @@ +import unittest + +from sos.policies import Policy, import_policy +from sos.plugins import Plugin, IndependentPlugin, RedHatPlugin, DebianPlugin + +class FauxPolicy(Policy): + distro = "Faux" + +class FauxPlugin(Plugin, IndependentPlugin): + pass + +class FauxRedHatPlugin(Plugin, RedHatPlugin): + pass + +class FauxDebianPlugin(Plugin, DebianPlugin): + pass + +class PolicyTests(unittest.TestCase): + + def test_independent_only(self): + p = FauxPolicy() + p.valid_subclasses = [] + + self.assertTrue(p.validatePlugin(FauxPlugin)) + + def test_redhat(self): + p = FauxPolicy() + p.valid_subclasses = [RedHatPlugin] + + self.assertTrue(p.validatePlugin(FauxRedHatPlugin)) + + def test_debian(self): + p = FauxPolicy() + p.valid_subclasses = [DebianPlugin] + + self.assertTrue(p.validatePlugin(FauxDebianPlugin)) + + def test_fails(self): + p = FauxPolicy() + p.valid_subclasses = [] + + self.assertFalse(p.validatePlugin(FauxDebianPlugin)) + + def test_can_import(self): + self.assertTrue(import_policy('redhat') is not None) + + def test_cant_import(self): + self.assertTrue(import_policy('notreal') is None) + +if __name__ == "__main__": + unittest.main() |