def breadcrumb(self) -> Breadcrumb: # To be able to calculate the breadcrumb with ModeCheckPluginTopic as parent, we need to # ensure that the topic is available. with request.stashed_vars(): request.request.set_var("topic", self._manpage["header"]["catalog"]) return super().breadcrumb()
def test_filters_filter_table(register_builtin_html, test, monkeypatch): # Needed for DeploymentTristateFilter test def deployment_states(host_name): return { "abc": { "target_aghash": "abc", }, "zzz": {}, }[host_name] if not cmk_version.is_raw_edition(): import cmk.gui.cee.agent_bakery as agent_bakery # pylint: disable=redefined-outer-name,import-outside-toplevel,no-name-in-module monkeypatch.setattr(agent_bakery, "get_cached_deployment_status", deployment_states) # Needed for FilterInvFloat test monkeypatch.setattr(cmk.gui.inventory, "get_inventory_data", get_inventory_data_patch) # Needed for FilterAggrServiceUsed test def is_part_of_aggregation_patch(host, service): return { ("h", "srv1"): True }.get((host, service), False) monkeypatch.setattr(cmk.gui.bi, "is_part_of_aggregation", is_part_of_aggregation_patch) with request.stashed_vars(), on_time('2018-04-15 16:50', 'CET'): request.del_vars() for key, val in test.request_vars: request.set_var(key, val) # TODO: Fix this for real... if not cmk_version.is_raw_edition or test.ident != "deployment_has_agent": filt = cmk.gui.plugins.visuals.utils.filter_registry[test.ident] assert filt.filter_table({}, test.rows) == test.expected_rows
def test_filters_display_with_empty_request(register_builtin_html, live): with live, request.stashed_vars(): request.del_vars() for filt in cmk.gui.plugins.visuals.utils.filter_registry.values(): with output_funnel.plugged(): _set_expected_queries(filt.ident, live) filt.display()
def breadcrumb(self) -> Breadcrumb: # The ModeEditRuleset.breadcrumb_item does not know anything about the fact that this mode # is a child of the logwatch_rules ruleset. It can not construct the correct link to the # logwatch_rules ruleset in the breadcrumb. We hand over the ruleset variable name that we # are interested in to the mode. It's a bit hacky to do it this way, but it's currently the # only way to get these information to the modes breadcrumb method. with request.stashed_vars(): request.set_var("varname", "logwatch_rules") request.del_var("host") request.del_var("service") return super().breadcrumb()
def test_filters_filter_with_empty_request(register_builtin_html, filter_ident, live): if filter_ident == "hostgroupvisibility": expected_filter = "Filter: hostgroup_num_hosts > 0\n" else: expected_filter = "" with live(expect_status_query=False), request.stashed_vars(): request.del_vars() filt = cmk.gui.plugins.visuals.utils.filter_registry[filter_ident] assert filt.filter(infoname="bla") == expected_filter
def test_filters_filter(register_builtin_html, test, monkeypatch): # Needed for ABCFilterCustomAttribute monkeypatch.setattr(cmk.gui.config, "wato_host_attrs", [{"name": "bla", "title": "Bla"}]) # Need for ABCTagFilter monkeypatch.setattr(cmk.gui.config, "tags", cmk.utils.tags.BuiltinTagConfig()) with request.stashed_vars(), on_time('2018-04-15 16:50', 'CET'): request.del_vars() for key, val in test.request_vars: request.set_var(key, val) filt = cmk.gui.plugins.visuals.utils.filter_registry[test.ident] assert filt.filter(infoname="bla") == test.expected_filters