split tables from records
[sfa.git] / tests / testHierarchy.py
1 import unittest
2 import os
3 from excep import *
4 from hierarchy import *
5 from config import *
6
7 BASEDIR = "test_hierarchy"
8 PURGE_BASEDIR = "rm -rf test_hierarchy"
9
10 class TestHierarchy(unittest.TestCase):
11     def setUp(self):
12         os.system(PURGE_BASEDIR)
13         pass
14
15     def testInit(self):
16         h = Hierarchy(BASEDIR)
17
18     def testGetAuthInfo(self):
19         h = Hierarchy(BASEDIR)
20
21         name = "planetlab.us.arizona.stork"
22
23         self.assertEqual(h.auth_exists(name), False)
24
25         self.assertRaises(MissingAuthority, h.get_auth_info, name)
26
27         h.create_auth(name, create_parents=True)
28         auth_info = h.get_auth_info(name)
29         self.assert_(auth_info)
30
31         gid = auth_info.get_gid_object()
32         self.assert_(gid)
33         self.assertEqual(gid.get_subject(), name)
34
35         pubkey = auth_info.get_pkey_object()
36         self.assert_(gid)
37
38         # try to get it again, make sure it's still there
39         auth_info2 = h.get_auth_info(name)
40         self.assert_(auth_info2)
41
42         gid = auth_info2.get_gid_object()
43         self.assert_(gid)
44         self.assertEqual(gid.get_subject(), name)
45
46         pubkey = auth_info2.get_pkey_object()
47         self.assert_(gid)
48
49
50 if __name__ == "__main__":
51     unittest.main()