aboutsummaryrefslogtreecommitdiffstats
path: root/tests/policy_tests.py
diff options
context:
space:
mode:
authorjhjaggars <jhjaggars@gmail.com>2012-02-23 13:39:04 -0800
committerjhjaggars <jhjaggars@gmail.com>2012-02-23 13:39:04 -0800
commita644f995f5ed5c900293b440431443963fef8855 (patch)
tree7d417249ee9ffed1b98233a46202f329b1adb7f6 /tests/policy_tests.py
parent237f8a0cdfc211126d962fd5dae3790f8599b41d (diff)
parentba01d5cbc1d83e09868eb0605f70e6c5bfbf20ad (diff)
downloadsos-a644f995f5ed5c900293b440431443963fef8855.tar.gz
Merge pull request #33 from jhjaggars/policy_refactoring
refactoring common linux-related policy features into a common superclas...
Diffstat (limited to 'tests/policy_tests.py')
-rw-r--r--tests/policy_tests.py51
1 files changed, 51 insertions, 0 deletions
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()