def test_active_check_execution(site: Site, web):
    rule_id = site.openapi.create_rule(
        ruleset_name="custom_checks",
        value={
            "service_description": "\xc4ctive-Check",
            "command_line": 'echo "123"',
        },
    )
    try:
        site.activate_changes_and_wait_for_core_reload()

        site.schedule_check("test-host", "\xc4ctive-Check", 0)

        result = site.live.query_row(
            "GET services\nColumns: host_name description state plugin_output has_been_checked\nFilter: host_name = test-host\nFilter: description = \xc4ctive-Check"
        )
        print("Result: %r" % result)
        assert result[4] == 1
        assert result[0] == "test-host"
        assert result[1] == "\xc4ctive-Check"
        assert result[2] == 0
        assert result[3] == "123"
    finally:
        site.openapi.delete_rule(rule_id)
        site.activate_changes_and_wait_for_core_reload()
def test_active_check_execution(site: Site, web):
    try:
        web.set_ruleset(  # Replace with RestAPI, see CMK-9251
            "custom_checks",
            {
                "ruleset": {
                    # Main folder
                    "": [
                        {
                            "value": {
                                "service_description": "\xc4ctive-Check",
                                "command_line": 'echo "123"',
                            },
                            "condition": {},
                            "options": {},
                        },
                    ],
                }
            },
        )
        site.activate_changes_and_wait_for_core_reload()

        site.schedule_check("test-host", "\xc4ctive-Check", 0)

        result = site.live.query_row(
            "GET services\nColumns: host_name description state plugin_output has_been_checked\nFilter: host_name = test-host\nFilter: description = \xc4ctive-Check"
        )
        print("Result: %r" % result)
        assert result[4] == 1
        assert result[0] == "test-host"
        assert result[1] == "\xc4ctive-Check"
        assert result[2] == 0
        assert result[3] == "123"
    finally:
        web.set_ruleset(  # Replace with RestAPI, see CMK-9251
            "custom_checks",
            {
                "ruleset": {
                    "": [],  # -> folder
                }
            },
        )
        site.activate_changes_and_wait_for_core_reload()