-
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.
fix(anta.tests): AntaTest.Input subclasses using common input models …
…should have validators for their required fields. (#1013) * Added validators for required fields * added unit tests for input validators * Fix docstrings --------- Co-authored-by: Carl Baillargeon <carl.baillargeon@arista.com>
- Loading branch information
1 parent
ab57f89
commit e0545a8
Showing
6 changed files
with
139 additions
and
11 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
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
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
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
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,41 @@ | ||
# 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.""" | ||
|
||
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