def _drop_all_other_policies(self, test_policy): policy_dbs = [ policy_db for policy_db in Policy.get_all() if policy_db.ref != test_policy ] for policy_db in policy_dbs: Policy.delete(policy_db, publish=False)
def test_delete_sys_pack(self): instance = self.__create_instance() instance['pack'] = 'core' post_resp = self.__do_post(instance) self.assertEqual(post_resp.status_int, http_client.CREATED) del_resp = self.__do_delete(self.__get_obj_id(post_resp)) self.assertEqual(del_resp.status_int, http_client.BAD_REQUEST) self.assertEqual(del_resp.json['faultstring'], "Resources belonging to system level packs can't be manipulated") # Clean up manually since API won't delete object in sys pack. Policy.delete(Policy.get_by_id(self.__get_obj_id(post_resp)))
def test_delete_sys_pack(self): instance = self.__create_instance() instance['pack'] = 'core' post_resp = self.__do_post(instance) self.assertEqual(post_resp.status_int, http_client.CREATED) del_resp = self.__do_delete(self.__get_obj_id(post_resp)) self.assertEqual(del_resp.status_int, http_client.BAD_REQUEST) self.assertEqual(del_resp.json['faultstring'], "Resources belonging to system level packs can't be manipulated") # Clean up manually since API won't delete object in sys pack. Policy.delete(Policy.get_by_id(self.__get_obj_id(post_resp)))
def test_put_sys_pack(self): instance = self.__create_instance() instance["pack"] = "core" post_resp = self.__do_post(instance) self.assertEqual(post_resp.status_int, http_client.CREATED) updated_input = post_resp.json updated_input["enabled"] = not updated_input["enabled"] put_resp = self.__do_put(self.__get_obj_id(post_resp), updated_input) self.assertEqual(put_resp.status_int, http_client.BAD_REQUEST) self.assertEqual( put_resp.json["faultstring"], "Resources belonging to system level packs can't be manipulated", ) # Clean up manually since API won't delete object in sys pack. Policy.delete(Policy.get_by_id(self.__get_obj_id(post_resp)))
def _drop_all_other_policies(self, test_policy): policy_dbs = [policy_db for policy_db in Policy.get_all() if policy_db.ref != test_policy] for policy_db in policy_dbs: Policy.delete(policy_db, publish=False)