aboutsummaryrefslogtreecommitdiffstats
path: root/tests/policy_tests.py
diff options
context:
space:
mode:
authorJesse Jaggars <jjaggars@redhat.com>2012-02-23 12:25:02 -0600
committerJesse Jaggars <jjaggars@redhat.com>2012-02-23 12:25:02 -0600
commit69292ec4022534f6987f1d67d4aefb07a983c38d (patch)
tree17898a09f8d6bc8b03f42ddf7a2c3621241f9261 /tests/policy_tests.py
parent9c102d30a49d123289191e1794dc7224f00e1983 (diff)
downloadsos-69292ec4022534f6987f1d67d4aefb07a983c38d.tar.gz
refactoring common linux-related policy features into a common superclass, simplifying specification of valid plugin subclasses
Diffstat (limited to 'tests/policy_tests.py')
-rw-r--r--tests/policy_tests.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/policy_tests.py b/tests/policy_tests.py
new file mode 100644
index 00000000..1c192bdf
--- /dev/null
+++ b/tests/policy_tests.py
@@ -0,0 +1,45 @@
+import unittest
+
+from sos.policies 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))
+
+if __name__ == "__main__":
+ unittest.main()