6 from qa.PLCs import PLC, PLCs
8 class delete_test_data(Test):
10 Removes the test data found in config from the plc db
13 def call(self, plc_name = None):
15 # Determine which plc to talk to
16 plc = PLC(self.config)
17 plcs = getattr(self.config, 'plcs', [])
19 if p['name'] in [plc_name]:
21 plc.config.update_api(plc)
24 auth = plc.config.auth
26 # Search config for objects that belong to this plc
27 # Any object with 'plc' defined as this plc's name or with
28 # no 'plc' defined will be added
29 this_plc = lambda object: 'plc' not in object or \
30 'plc' in object and object['plc'] == plc['name'] or \
33 sitelist = filter(this_plc, self.config.sites)
35 # Deleting the site should delete everything associated with it
36 # including nodes, persons
39 api.DeleteSite(auth, site['login_base'])
40 if self.config.verbose:
41 utils.header("Test data deleted")
43 if self.config.verbose:
44 utils.header("Error deleting %s" % site['login_base'])
47 if __name__ == '__main__':
48 args = tuple(sys.argv[1:])
49 delete_test_data()(*args)