Merging upstream version 1.2.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-05 11:55:22 +01:00
parent ae7b7df396
commit afeccccd6a
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
154 changed files with 7346 additions and 5000 deletions

View file

@ -11,7 +11,7 @@ from typing import Any
import pytest
from anta.tools import convert_categories, custom_division, get_dict_superset, get_failed_logs, get_item, get_value
from anta.tools import convert_categories, custom_division, format_data, 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"},
@ -513,3 +513,17 @@ def test_convert_categories(test_input: list[str], expected_raise: AbstractConte
"""Test convert_categories."""
with expected_raise:
assert convert_categories(test_input) == expected_result
@pytest.mark.parametrize(
("input_data", "expected_output"),
[
pytest.param({"advertised": True, "received": True, "enabled": True}, "Advertised: True, Received: True, Enabled: True", id="multiple entry, all True"),
pytest.param({"advertised": False, "received": False}, "Advertised: False, Received: False", id="multiple entry, all False"),
pytest.param({}, "", id="empty dict"),
pytest.param({"test": True}, "Test: True", id="single entry"),
],
)
def test_format_data(input_data: dict[str, bool], expected_output: str) -> None:
"""Test format_data."""
assert format_data(input_data) == expected_output