split tables from records
[sfa.git] / tests / testRights.py
1 import unittest
2 from rights import *
3
4 class TestRight(unittest.TestCase):
5    def setUp(self):
6       pass
7
8    def testRightInit(self):
9       right = Right("embed")
10       self.assertEqual(right.kind, "embed")
11
12    def testRightCanPerform(self):
13       right = Right("embed")
14       self.assert_(right.can_perform("getticket"))
15       self.assert_(not right.can_perform("resolve"))
16
17 class TestRightList(unittest.TestCase):
18     def setUp(self):
19         pass
20
21     def testInit(self):
22         # create a blank right list
23         rightList = RightList()
24
25         # create a right list with "embed" in it
26         rightList = RightList(string="embed")
27
28     def testAsString(self):
29         rightList = RightList()
30         self.assertEqual(rightList.save_to_string(), "")
31
32         rightList = RightList(string="embed")
33         self.assertEqual(rightList.save_to_string(), "embed")
34
35         rightList = RightList(string="embed,resolve")
36         self.assertEqual(rightList.save_to_string(), "embed,resolve")
37
38     def testCanPerform(self):
39         rightList = RightList(string="embed")
40         self.assert_(rightList.can_perform("getticket"))
41         self.assert_(not rightList.can_perform("resolve"))
42
43         rightList = RightList(string="embed,resolve")
44         self.assert_(rightList.can_perform("getticket"))
45         self.assert_(rightList.can_perform("resolve"))
46
47
48 if __name__ == "__main__":
49     unittest.main()