diff options
Diffstat (limited to '')
-rw-r--r-- | tests/units/test_tools.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/tests/units/test_tools.py b/tests/units/test_tools.py index c3a57e5..16f0443 100644 --- a/tests/units/test_tools.py +++ b/tests/units/test_tools.py @@ -11,7 +11,7 @@ from typing import Any import pytest -from anta.tools import custom_division, get_dict_superset, get_failed_logs, get_item, get_value +from anta.tools import convert_categories, custom_division, get_dict_superset, get_failed_logs, get_item, get_value TEST_GET_FAILED_LOGS_DATA = [ {"id": 1, "name": "Alice", "age": 30, "email": "alice@example.com"}, @@ -313,7 +313,6 @@ def test_get_dict_superset( expected_raise: AbstractContextManager[Exception], ) -> None: """Test get_dict_superset.""" - # pylint: disable=too-many-arguments with expected_raise: assert get_dict_superset(list_of_dicts, input_dict, default, var_name, custom_error_msg, required=required) == expected_result @@ -421,7 +420,6 @@ def test_get_value( expected_raise: AbstractContextManager[Exception], ) -> None: """Test get_value.""" - # pylint: disable=too-many-arguments kwargs = { "default": default, "required": required, @@ -485,7 +483,6 @@ def test_get_item( expected_raise: AbstractContextManager[Exception], ) -> None: """Test get_item.""" - # pylint: disable=too-many-arguments with expected_raise: assert get_item(list_of_dicts, key, value, default, var_name, custom_error_msg, required=required, case_sensitive=case_sensitive) == expected_result @@ -502,3 +499,17 @@ def test_get_item( def test_custom_division(numerator: float, denominator: float, expected_result: str) -> None: """Test custom_division.""" assert custom_division(numerator, denominator) == expected_result + + +@pytest.mark.parametrize( + ("test_input", "expected_raise", "expected_result"), + [ + pytest.param([], does_not_raise(), [], id="empty list"), + pytest.param(["bgp", "system", "vlan", "configuration"], does_not_raise(), ["BGP", "System", "VLAN", "Configuration"], id="list with acronyms and titles"), + pytest.param(42, pytest.raises(TypeError, match="Wrong input type"), None, id="wrong input type"), + ], +) +def test_convert_categories(test_input: list[str], expected_raise: AbstractContextManager[Exception], expected_result: list[str]) -> None: + """Test convert_categories.""" + with expected_raise: + assert convert_categories(test_input) == expected_result |