Merging upstream version 1.1.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-05 11:54:55 +01:00
parent 50f8dbf7e8
commit 2044ea6182
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
196 changed files with 10121 additions and 3780 deletions

View file

@ -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