2 from sfa.trust.rights import *
4 class TestRight(unittest.TestCase):
8 def testRightInit(self):
10 self.assertEqual(right.kind, "embed")
12 def testRightCanPerform(self):
13 right = Right("embed")
14 self.assertTrue(right.can_perform("getticket"))
15 self.assertTrue(not right.can_perform("resolve"))
17 def testIsSuperset(self):
19 cright = Right("embed")
20 self.assertTrue(pright.is_superset(cright))
21 self.assertTrue(not cright.is_superset(pright))
23 pright = Right("embed")
24 cright = Right("embed")
25 self.assertTrue(pright.is_superset(cright))
26 self.assertTrue(cright.is_superset(pright))
28 pright = Right("control")
29 cright = Right("embed")
30 self.assertTrue(not pright.is_superset(cright))
31 self.assertTrue(not cright.is_superset(pright))
33 class TestRights(unittest.TestCase):
38 # create a blank right list
41 # create a right list with "embed" in it
42 rightList = Rights(string="embed")
44 def testAsString(self):
46 self.assertEqual(rightList.save_to_string(), "")
48 rightList = Rights(string="embed")
49 self.assertEqual(rightList.save_to_string(), "embed")
51 rightList = Rights(string="embed,resolve")
52 self.assertEqual(rightList.save_to_string(), "embed,resolve")
54 def testCanPerform(self):
55 rightList = Rights(string="embed")
56 self.assertTrue(rightList.can_perform("getticket"))
57 self.assertTrue(not rightList.can_perform("resolve"))
59 rightList = Rights(string="embed,resolve")
60 self.assertTrue(rightList.can_perform("getticket"))
61 self.assertTrue(rightList.can_perform("resolve"))
63 def testIsSuperset(self):
64 pRights = Rights(string="sa")
65 cRights = Rights(string="embed")
66 self.assertTrue(pRights.is_superset(cRights))
67 self.assertTrue(not cRights.is_superset(pRights))
69 pRights = Rights(string="embed")
70 cRights = Rights(string="embed")
71 self.assertTrue(pRights.is_superset(cRights))
72 self.assertTrue(cRights.is_superset(pRights))
74 pRights = Rights(string="control")
75 cRights = Rights(string="embed")
76 self.assertTrue(not pRights.is_superset(cRights))
77 self.assertTrue(not cRights.is_superset(pRights))
79 pRights = Rights(string="control,sa")
80 cRights = Rights(string="embed")
81 self.assertTrue(pRights.is_superset(cRights))
82 self.assertTrue(not cRights.is_superset(pRights))
85 if __name__ == "__main__":