summaryrefslogtreecommitdiffstats
path: root/tests/units/tools/test_utils.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 08:36:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 08:36:50 +0000
commit7763cc454d686d51bf2e0ccc1f2ccf7d62a0d625 (patch)
treef36d2006dd01bd01a069956741d831d9d5633377 /tests/units/tools/test_utils.py
parentAdding debian version 0.13.0-1. (diff)
downloadanta-7763cc454d686d51bf2e0ccc1f2ccf7d62a0d625.tar.xz
anta-7763cc454d686d51bf2e0ccc1f2ccf7d62a0d625.zip
Merging upstream version 0.14.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/units/tools/test_utils.py57
1 files changed, 0 insertions, 57 deletions
diff --git a/tests/units/tools/test_utils.py b/tests/units/tools/test_utils.py
deleted file mode 100644
index 448324f..0000000
--- a/tests/units/tools/test_utils.py
+++ /dev/null
@@ -1,57 +0,0 @@
-# Copyright (c) 2023-2024 Arista Networks, Inc.
-# Use of this source code is governed by the Apache License 2.0
-# that can be found in the LICENSE file.
-
-"""Tests for `anta.tools.utils`."""
-from __future__ import annotations
-
-from contextlib import nullcontext as does_not_raise
-from typing import Any
-
-import pytest
-
-from anta.tools.utils import get_failed_logs
-
-EXPECTED_OUTPUTS = [
- {"id": 1, "name": "Alice", "age": 30, "email": "alice@example.com"},
- {"id": 2, "name": "Bob", "age": 35, "email": "bob@example.com"},
- {"id": 3, "name": "Charlie", "age": 40, "email": "charlie@example.com"},
- {"id": 4, "name": "Jon", "age": 25, "email": "Jon@example.com"},
-]
-
-ACTUAL_OUTPUTS = [
- {"id": 1, "name": "Alice", "age": 30, "email": "alice@example.com"},
- {"id": 2, "name": "Bob", "age": 35, "email": "bob@example.com"},
- {"id": 3, "name": "Charlie", "age": 40, "email": "charlie@example.com"},
- {"id": 4, "name": "Rob", "age": 25, "email": "Jon@example.com"},
-]
-
-
-@pytest.mark.parametrize(
- "expected_output, actual_output, expected_result, expected_raise",
- [
- pytest.param(EXPECTED_OUTPUTS[0], ACTUAL_OUTPUTS[0], "", does_not_raise(), id="no difference"),
- pytest.param(
- EXPECTED_OUTPUTS[0],
- ACTUAL_OUTPUTS[1],
- "\nExpected `1` as the id, but found `2` instead.\nExpected `Alice` as the name, but found `Bob` instead.\n"
- "Expected `30` as the age, but found `35` instead.\nExpected `alice@example.com` as the email, but found `bob@example.com` instead.",
- does_not_raise(),
- id="different data",
- ),
- pytest.param(
- EXPECTED_OUTPUTS[0],
- {},
- "\nExpected `1` as the id, but it was not found in the actual output.\nExpected `Alice` as the name, but it was not found in the actual output.\n"
- "Expected `30` as the age, but it was not found in the actual output.\nExpected `alice@example.com` as the email, but it was not found in "
- "the actual output.",
- does_not_raise(),
- id="empty actual output",
- ),
- pytest.param(EXPECTED_OUTPUTS[3], ACTUAL_OUTPUTS[3], "\nExpected `Jon` as the name, but found `Rob` instead.", does_not_raise(), id="different name"),
- ],
-)
-def test_get_failed_logs(expected_output: dict[Any, Any], actual_output: dict[Any, Any], expected_result: str, expected_raise: Any) -> None:
- """Test get_failed_logs."""
- with expected_raise:
- assert get_failed_logs(expected_output, actual_output) == expected_result