Пример #1
0
def test_get_default_params_ignore_user_defined_tuple():
    # with params
    assert check_utils.get_default_parameters(
        check_legacy_info={"default_levels_variable": "foo"},
        factory_settings={},
        check_context={"foo": (23, 42)},
    ) == {}
Пример #2
0
def test_get_default_params_clean_case():
    # with params
    assert check_utils.get_default_parameters(
        check_legacy_info={"default_levels_variable": "foo"},
        factory_settings={"foo": {
            "levels": (23, 42)
        }},
        check_context={},
    ) == {
        "levels": (23, 42)
    }

    # without params
    assert check_utils.get_default_parameters(
        check_legacy_info={},
        factory_settings={},
        check_context={},
    ) is None
Пример #3
0
def _create_wrapped_parameters(check_plugin_name: str,
                               check_info_dict: Dict[str, Any]) -> Optional[Dict[str, Any]]:
    """compute default parameters and wrap them in a dictionary"""
    default_parameters = get_default_parameters(
        check_info_dict,
        config.factory_settings,
        config.get_check_context(check_plugin_name),
    )
    if default_parameters is None:
        return {} if check_info_dict.get("group") else None

    if isinstance(default_parameters, dict):
        return default_parameters
    return wrap_parameters(default_parameters)
Пример #4
0
def test_get_default_params_with_user_update():
    # with params
    assert check_utils.get_default_parameters(
        check_legacy_info={"default_levels_variable": "foo"},
        factory_settings={"foo": {
            "levels": (23, 42),
            "overwrite_this": None
        }},
        check_context={"foo": {
            "overwrite_this": 3.14,
            "more": "is better!"
        }},
    ) == {
        "levels": (23, 42),
        "overwrite_this": 3.14,
        "more": "is better!",
    }
Пример #5
0
def _create_wrapped_parameters(
    check_plugin_name: str,
    check_info_dict: Dict[str, Any],
    factory_settings: Dict[str, Dict],
    get_check_context: Callable,
) -> Dict[str, Any]:
    """compute default parameters and wrap them in a dictionary"""
    default_parameters = get_default_parameters(
        check_info_dict,
        factory_settings,
        get_check_context(check_plugin_name),
    )
    if default_parameters is None:
        return {}

    if isinstance(default_parameters, dict):
        return default_parameters
    return wrap_parameters(default_parameters)