def test_remove_removed_check_plugins_from_ignored_checks( uc: update_config.UpdateConfig) -> None: ruleset = Ruleset("ignored_checks", {}) ruleset.from_config( Folder(""), [ { "id": "1", "condition": {}, "options": { "disabled": False }, "value": ["a", "b", "mgmt_c"], }, { "id": "2", "condition": {}, "options": { "disabled": False }, "value": ["d", "e"], }, { "id": "3", "condition": {}, "options": { "disabled": False }, "value": ["mgmt_f"], }, { "id": "4", "condition": {}, "options": { "disabled": False }, "value": ["a", "g"], }, ], ) rulesets = RulesetCollection() rulesets.set_rulesets({"ignored_checks": ruleset}) uc._remove_removed_check_plugins_from_ignored_checks( rulesets, { CheckPluginName("b"), CheckPluginName("d"), CheckPluginName("e"), CheckPluginName("f"), }, ) leftover_rules = [ rule for (_folder, idx, rule) in rulesets.get("ignored_checks").get_rules() ] assert len(leftover_rules) == 2 assert leftover_rules[0].id == "1" assert leftover_rules[1].id == "4" assert leftover_rules[0].value == ["a", "mgmt_c"] assert leftover_rules[1].value == ["a", "g"]
def test__transform_replaced_wato_rulesets_and_params( uc: update_config.UpdateConfig, ruleset_name: RulesetName, param_value: RuleValue, new_ruleset_name: RulesetName, transformed_param_value: RuleValue, ) -> None: all_rulesets = RulesetCollection() # checkmk: all_rulesets are loaded via # all_rulesets = cmk.gui.watolib.rulesets.AllRulesets() all_rulesets.set_rulesets({ ruleset_name: _instantiate_ruleset(ruleset_name, param_value), new_ruleset_name: Ruleset(new_ruleset_name, {}), }) uc._transform_replaced_wato_rulesets(all_rulesets) uc._transform_wato_rulesets_params(all_rulesets) assert not all_rulesets.exists(ruleset_name) rules = all_rulesets.get(new_ruleset_name).get_rules() assert len(rules) == 1 rule = rules[0] assert len(rule) == 3 assert rule[2].value == transformed_param_value