Ejemplo n.º 1
0
def test_legacy_icon_plugin_defaults(monkeypatch):
    icon = {
        "columns": ["column"],
        "host_columns": ["hcol"],
        "service_columns": ["scol"],
        "paint": lambda: "bla",
    }
    monkeypatch.setitem(cmk.gui.views.multisite_icons_and_actions, "legacy",
                        icon)
    cmk.gui.views.transform_old_dict_based_icons()

    registered_icon = get_multisite_icons()["legacy"]
    assert registered_icon.toplevel() is False
    assert registered_icon.sort_index() == 30
Ejemplo n.º 2
0
def test_builtin_icons_and_actions():
    expected_icons_and_actions = [
        "action_menu",
        "aggregation_checks",
        "aggregations",
        "check_manpage",
        "check_period",
        "crashed_check",
        "custom_action",
        "download_agent_output",
        "download_snmp_walk",
        "icon_image",
        "inventory",
        "logwatch",
        "mkeventd",
        "notes",
        "parent_child_topology",
        "perfgraph",
        "prediction",
        "reschedule",
        "robotmk",
        "robotmk_error",
        "rule_editor",
        "stars",
        "status_acknowledged",
        "status_active_checks",
        "status_comments",
        "status_downtimes",
        "status_flapping",
        "status_notification_period",
        "status_notifications_enabled",
        "status_passive_checks",
        "status_service_period",
        "status_stale",
        "wato",
    ]

    if not cmk_version.is_raw_edition():
        expected_icons_and_actions += [
            "agent_deployment",
            "deployment_status",
            "status_shadow",
            "ntop_host",
        ]

    cmk.gui.views.transform_old_dict_based_icons()
    builtin_icons = sorted(get_multisite_icons().keys())
    assert builtin_icons == sorted(expected_icons_and_actions)
Ejemplo n.º 3
0
def test_legacy_icon_plugin(monkeypatch):
    icon: Dict[str, Any] = {
        "columns": ["column"],
        "host_columns": ["hcol"],
        "service_columns": ["scol"],
        "paint": lambda what, row, tags, custom_vars: "bla",
        "sort_index": 10,
        "toplevel": True,
    }
    monkeypatch.setitem(cmk.gui.views.multisite_icons_and_actions, "legacy",
                        icon)
    cmk.gui.views.transform_old_dict_based_icons()

    registered_icon = get_multisite_icons()["legacy"]
    assert registered_icon.columns() == icon["columns"]
    assert registered_icon.host_columns() == icon["host_columns"]
    assert registered_icon.service_columns() == icon["service_columns"]
    assert registered_icon.render("host", {}, [],
                                  {}) == icon["paint"]("host", {}, [], {})
    assert registered_icon.toplevel() is True
    assert registered_icon.sort_index() == 10
Ejemplo n.º 4
0
def test_icon_options(args, result, request_context, monkeypatch):
    """Creation of title and url for links to event console entries of host"""
    icon = get_multisite_icons()["mkeventd"]

    def _get_dummy_hostname(args, row):
        args_splitted = args[0].split("/")
        if args_splitted[0] == "$HOSTNAME$":
            return row["host_name"]
        if args_splitted[0] == "$HOSTADDRESS$":
            return row["host_address"]
        if args_splitted[0] == "$HOSTALIAS$":
            return "my_alias"
        return args[0]

    monkeypatch.setattr(
        mkeventd_icon,
        "_get_hostname",
        _get_dummy_hostname,
    )

    assert icon.render(args.what, args.row, args.tags,
                       args.custom_vars) == result