| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
"""Tests for anta.input_models.connectivity.py.""" |
| 5 |
|
| 6 |
|
| 7 |
from __future__ import annotations |
| 8 |
|
| 9 |
from typing import TYPE_CHECKING |
| 10 |
|
| 11 |
import pytest |
| 12 |
from pydantic import ValidationError |
| 13 |
|
| 14 |
from anta.tests.connectivity import VerifyReachability |
| 15 |
|
| 16 |
if TYPE_CHECKING: |
| 17 |
from anta.input_models.connectivity import Host |
| 18 |
|
| 19 |
|
| 20 |
class TestVerifyReachabilityInput: |
| 21 |
"""Test anta.tests.connectivity.VerifyReachability.Input.""" |
| 22 |
|
| 23 |
@pytest.mark.parametrize( |
| 24 |
("hosts"), |
| 25 |
[ |
| 26 |
pytest.param([{"destination": "fd12:3456:789a:1::2", "source": "fd12:3456:789a:1::1"}], id="valid"), |
| 27 |
], |
| 28 |
) |
| 29 |
def test_valid(self, hosts: list[Host]) -> None: |
| 30 |
"""Test VerifyReachability.Input valid inputs.""" |
| 31 |
VerifyReachability.Input(hosts=hosts) |
| 32 |
|
| 33 |
@pytest.mark.parametrize( |
| 34 |
("hosts"), |
| 35 |
[ |
| 36 |
pytest.param([{"destination": "fd12:3456:789a:1::2", "source": "192.168.0.10"}], id="invalid-source"), |
| 37 |
pytest.param([{"destination": "192.168.0.10", "source": "fd12:3456:789a:1::2"}], id="invalid-destination"), |
| 38 |
], |
| 39 |
) |
| 40 |
def test_invalid(self, hosts: list[Host]) -> None: |
| 41 |
"""Test VerifyReachability.Input invalid inputs.""" |
| 42 |
with pytest.raises(ValidationError): |
| 43 |
VerifyReachability.Input(hosts=hosts) |