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(),
29 self.site_spec['address_fields'])
31 def create_users (self):
32 for user_spec in self.site_spec['users']:
33 test_user = TestUser(self.test_plc, self, user_spec)
34 test_user.create_user()
37 def delete_site (self):
38 print(self.test_plc.auth_root())
39 self.test_plc.apiserver.DeleteSite(self.test_plc.auth_root(), self.name())
42 def delete_users(self):
43 for user_spec in self.site_spec['users']:
44 test_user = TestUser(self.test_plc, self, user_spec)
45 test_user.delete_user()
47 def locate_user (self, username):
48 for user in self.site_spec['users']:
49 if user['name'] == username:
51 if user['user_fields']['email'] == username:
53 raise Exception("Cannot locate user {}".format(username))
55 def locate_node (self, nodename):
56 for node in self.site_spec['nodes']:
57 if node['name'] == nodename:
59 raise Exception("Cannot locate node {}".format(nodename))