Skip to content

Commit

Permalink
legacy conversion: drop handle_empty_info
Browse files Browse the repository at this point in the history
This property is not set in any of the remaining plugins.

Change-Id: I2091fcc74b234c4f0e3e708dfbc4fb4c86f2c076
  • Loading branch information
mo-ki committed Dec 13, 2023
1 parent 7d9257b commit ba6856b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
8 changes: 2 additions & 6 deletions cmk/base/api/agent_based/register/section_plugins_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def parse_function(string_table: StringTable) -> Any:

def _create_snmp_parse_function(
original_parse_function: Callable | None,
handle_empty_info: bool,
) -> Callable[[Any], object]: # sorry, but this is what we know.
"""Wrap parse function to comply to new API
Expand All @@ -66,7 +65,7 @@ def _create_snmp_parse_function(

# do not use functools.wraps, the point is the new argument name!
def parse_function(string_table: Any) -> object:
if not handle_empty_info and not any(string_table):
if not any(string_table):
return None

if original_parse_function is None:
Expand Down Expand Up @@ -116,10 +115,7 @@ def create_snmp_section_plugin_from_legacy(
fetch = check_info_element["fetch"]
detect = cast(SNMPDetectSpecification, check_info_element["detect"])

parse_function = _create_snmp_parse_function(
check_info_element.get("parse_function"),
handle_empty_info=bool(check_info_element.get("handle_empty_info")),
)
parse_function = _create_snmp_parse_function(check_info_element.get("parse_function"))

return create_snmp_section_plugin(
SimpleSNMPSection( # ty#pe: ignore[call-overload]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ def test_create_agent_parse_function() -> None:

def test_create_snmp_parse_function() -> None:
compliant_parse_function = section_plugins_legacy._create_snmp_parse_function(
original_parse_function=old_school_parse_function,
handle_empty_info=False,
original_parse_function=old_school_parse_function
)

with pytest.raises(ValueError):
Expand All @@ -77,15 +76,6 @@ def test_create_snmp_parse_function() -> None:
)


def test_create_snmp_parse_function_handle_empty() -> None:
compliant_parse_function = section_plugins_legacy._create_snmp_parse_function(
original_parse_function=old_school_parse_function,
handle_empty_info=True,
)

assert compliant_parse_function([[]]) == old_school_parse_function([[]])


def test_create_snmp_section_plugin_from_legacy() -> None:
plugin = section_plugins_legacy.create_snmp_section_plugin_from_legacy(
"norris",
Expand Down

0 comments on commit ba6856b

Please sign in to comment.