Skip to content

Commit

Permalink
Updated unit tests for input models
Browse files Browse the repository at this point in the history
  • Loading branch information
vitthalmagadum committed Feb 11, 2025
1 parent 3c91d9e commit 5842f0c
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions tests/units/input_models/routing/test_isis.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@

from __future__ import annotations

from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Literal

import pytest
from pydantic import ValidationError

from anta.input_models.routing.isis import ISISInstance, TunnelPath
from anta.tests.routing.isis import VerifyISISSegmentRoutingAdjacencySegments, VerifyISISSegmentRoutingDataplane

if TYPE_CHECKING:
from anta.input_models.routing.isis import ISISInstance
from ipaddress import IPv4Address

from anta.custom_types import Interface


class TestVerifyISISSegmentRoutingAdjacencySegmentsInput:
Expand Down Expand Up @@ -68,3 +71,31 @@ def test_invalid(self, instances: list[ISISInstance]) -> None:
"""Test VerifyISISSegmentRoutingDataplane.Input invalid inputs."""
with pytest.raises(ValidationError):
VerifyISISSegmentRoutingDataplane.Input(instances=instances)


class TestTunnelPath:
"""Test anta.input_models.routing.isis.TestTunnelPath."""

# pylint: disable=too-few-public-methods

@pytest.mark.parametrize(
("nexthop", "type", "interface", "tunnel_id", "expected"),
[
pytest.param("1.1.1.1", None, None, None, "Next-hop: 1.1.1.1", id="nexthop"),
pytest.param(None, "ip", None, None, "Type: ip", id="type"),
pytest.param(None, None, "Et1", None, "Interface: Ethernet1", id="interface"),
pytest.param(None, None, None, "TI-LFA", "TunnelID: TI-LFA", id="tunnel_id"),
pytest.param("1.1.1.1", "ip", "Et1", "TI-LFA", "Next-hop: 1.1.1.1 Type: ip Interface: Ethernet1 TunnelID: TI-LFA", id="all"),
pytest.param(None, None, None, None, "", id="None"),
],
)
def test_valid__str__(
self,
nexthop: IPv4Address | None,
type: Literal["ip", "tunnel"] | None, # noqa: A002
interface: Interface | None,
tunnel_id: Literal["TI-LFA", "ti-lfa", "unset"] | None,
expected: str,
) -> None:
"""Test TunnelPath __str__."""
assert str(TunnelPath(nexthop=nexthop, type=type, interface=interface, tunnel_id=tunnel_id)) == expected

0 comments on commit 5842f0c

Please sign in to comment.