1 # Thierry Parmentelat <thierry.parmentelat@inria.fr>
2 # Copyright (C) 2010 INRIA
10 from TestNode import TestNode
11 from TestUser import TestUser
12 from TestKey import TestKey
16 def __init__ (self,test_plc,site_spec):
17 self.test_plc=test_plc
18 self.site_spec=site_spec
21 return self.site_spec['site_fields']['login_base']
23 def create_site (self):
24 print self.test_plc.auth_root()
25 self.test_plc.apiserver.AddSite(self.test_plc.auth_root(),
26 self.site_spec['site_fields'])
27 self.test_plc.apiserver.AddSiteAddress(self.test_plc.auth_root(),self.name(),
28 self.site_spec['address_fields'])
30 def create_users (self):
31 for user_spec in self.site_spec['users']:
32 test_user=TestUser(self.test_plc,self,user_spec)
33 test_user.create_user()
36 def delete_site (self):
37 print self.test_plc.auth_root()
38 self.test_plc.apiserver.DeleteSite(self.test_plc.auth_root(),self.name())
41 def delete_users(self):
42 for user_spec in self.site_spec['users']:
43 test_user=TestUser(self.test_plc,self,user_spec)
44 test_user.delete_user()
46 def locate_user (self,username):
47 for user in self.site_spec['users']:
48 if user['name'] == username:
50 if user['user_fields']['email'] == username:
52 raise Exception,"Cannot locate user %s"%username
54 def locate_node (self,nodename):
55 for node in self.site_spec['nodes']:
56 if node['name'] == nodename:
58 raise Exception,"Cannot locate node %s"%nodename