blob: 1c192bdf1ab87b1e7dd7f72852613a5380e94ce6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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()
|