def delete(self, force=False): """Cascade delete of DB records related to env. It deletes all Task and Verify results related to this env as well. :param force: Use it if you don't want to perform status check """ _status = self.status if not force and _status != STATUS.DESTROYED: raise exceptions.ManagerInvalidState( mgr="Env", expected=STATUS.DESTROYED, actual=_status) db.env_delete_cascade(self.uuid)
def test_env_delete_cascade(self): platforms = [{ "status": "ANY", "plugin_name": "plugin_%s@plugin" % i, "plugin_spec": {}, "platform_name": "plugin" } for i in range(3)] env = db.env_create("name", "status", "descr", {}, {}, {}, platforms) db.env_delete_cascade(env["uuid"]) self.assertEqual(0, len(db.env_list())) self.assertEqual(0, len(db.platforms_list(env["uuid"])))
def test_env_delete_cascade(self): platforms = [ { "status": "ANY", "plugin_name": "plugin_%s@plugin" % i, "plugin_spec": {}, "platform_name": "plugin" } for i in range(3) ] env = db.env_create("name", "status", "descr", {}, {}, {}, platforms) db.env_delete_cascade(env["uuid"]) self.assertEqual(0, len(db.env_list())) self.assertEqual(0, len(db.platforms_list(env["uuid"])))