-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added unit tests for input validators
- Loading branch information
1 parent
59b92e1
commit b751f9c
Showing
2 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# 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. | ||
"""Tests for anta.input_models.routing.generic.py.""" | ||
|
||
# pylint: disable=C0302 | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
import pytest | ||
from pydantic import ValidationError | ||
|
||
from anta.tests.routing.generic import VerifyIPv4RouteType | ||
|
||
if TYPE_CHECKING: | ||
from anta.input_models.routing.generic import IPv4Routes | ||
|
||
|
||
class TestVerifyIPv4RouteTypeInput: | ||
"""Test anta.tests.routing.bgp.VerifyIPv4RouteType.Input.""" | ||
|
||
@pytest.mark.parametrize( | ||
("routes_entries"), | ||
[ | ||
pytest.param([{"prefix": "192.168.0.0/24", "vrf": "default", "route_type": "eBGP"}], id="valid"), | ||
], | ||
) | ||
def test_valid(self, routes_entries: list[IPv4Routes]) -> None: | ||
"""Test VerifyIPv4RouteType.Input valid inputs.""" | ||
VerifyIPv4RouteType.Input(routes_entries=routes_entries) | ||
|
||
@pytest.mark.parametrize( | ||
("routes_entries"), | ||
[ | ||
pytest.param([{"prefix": "192.168.0.0/24", "vrf": "default"}], id="invalid"), | ||
], | ||
) | ||
def test_invalid(self, routes_entries: list[IPv4Routes]) -> None: | ||
"""Test VerifyIPv4RouteType.Input invalid inputs.""" | ||
with pytest.raises(ValidationError): | ||
VerifyIPv4RouteType.Input(routes_entries=routes_entries) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters