Adding upstream version 1.3.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
6fd6eb426a
commit
dc7df702ea
337 changed files with 16571 additions and 4891 deletions
|
@ -1,11 +1,11 @@
|
|||
# Copyright (c) 2023-2024 Arista Networks, Inc.
|
||||
# Copyright (c) 2023-2025 Arista Networks, Inc.
|
||||
# Use of this source code is governed by the Apache License 2.0
|
||||
# that can be found in the LICENSE file.
|
||||
"""ANTA Inventory unit tests."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
import logging
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
@ -15,11 +15,10 @@ from anta.inventory import AntaInventory
|
|||
from anta.inventory.exceptions import InventoryIncorrectSchemaError, InventoryRootKeyError
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from pathlib import Path
|
||||
|
||||
from _pytest.mark.structures import ParameterSet
|
||||
|
||||
FILE_DIR: Path = Path(__file__).parent.parent.resolve() / "data" / "inventory"
|
||||
|
||||
|
||||
INIT_VALID_PARAMS: list[ParameterSet] = [
|
||||
pytest.param(
|
||||
{"anta_inventory": {"hosts": [{"host": "192.168.0.17"}, {"host": "192.168.0.2"}, {"host": "my.awesome.host.com"}]}},
|
||||
|
@ -76,3 +75,15 @@ class TestAntaInventory:
|
|||
"""Parse invalid YAML file to create ANTA inventory."""
|
||||
with pytest.raises((InventoryIncorrectSchemaError, InventoryRootKeyError, ValidationError)):
|
||||
AntaInventory.parse(filename=yaml_file, username="arista", password="arista123")
|
||||
|
||||
def test_parse_wrong_format(self) -> None:
|
||||
"""Use wrong file format to parse the ANTA inventory."""
|
||||
with pytest.raises(ValueError, match=" is not a valid format for an AntaInventory file. Only 'yaml' and 'json' are supported."):
|
||||
AntaInventory.parse(filename="dummy.yml", username="arista", password="arista123", file_format="wrong") # type: ignore[arg-type]
|
||||
|
||||
def test_parse_os_error(self, caplog: pytest.LogCaptureFixture) -> None:
|
||||
"""Use wrong file name to parse the ANTA inventory."""
|
||||
caplog.set_level(logging.INFO)
|
||||
with pytest.raises(OSError, match="No such file or directory"):
|
||||
_ = AntaInventory.parse(filename="dummy.yml", username="arista", password="arista123")
|
||||
assert "Unable to parse ANTA Device Inventory file" in caplog.records[0].message
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue