Skip to content

Commit

Permalink
issue_822 Handling review comments: updated docstring, custom_types
Browse files Browse the repository at this point in the history
  • Loading branch information
VitthalMagadum committed Oct 3, 2024
1 parent 4261605 commit da8ba27
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions anta/custom_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,4 @@ def validate_regex(value: str) -> str:
]
BgpUpdateError = Literal["inUpdErrWithdraw", "inUpdErrIgnore", "inUpdErrDisableAfiSafi", "disabledAfiSafi", "lastUpdErrTime"]
BfdProtocol = Literal["bgp", "isis", "lag", "ospf", "ospfv3", "pim", "route-input", "static-bfd", "static-route", "vrrp", "vxlan"]
SnmpVersion = Literal["v1", "v2c", "v3"]
8 changes: 4 additions & 4 deletions anta/tests/snmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from pydantic import BaseModel, model_validator

from anta.custom_types import Port, PositiveInteger
from anta.custom_types import Port, PositiveInteger, SnmpVersion
from anta.models import AntaCommand, AntaTest
from anta.tools import get_failed_logs, get_item, get_value

Expand Down Expand Up @@ -282,15 +282,15 @@ class Input(AntaTest.Input):
"""List of SNMP hosts."""

class SNMPHost(BaseModel):
"""Model for a SNMP Manager."""
"""Model for a SNMP Host."""

hostname: IPv4Address
"""IPv4 address of the SNMP notification host."""
vrf: str = "default"
"""Optional VRF for SNMP Hosts. If not provided, it defaults to `default`."""
notification_type: Literal["trap", "inform"]
"""Type of SNMP notification (trap or inform)."""
version: Literal["v1", "v2c", "v3"]
version: SnmpVersion
"""SNMP protocol version."""
udp_port: Port | int = 162
"""UDP port for SNMP. If not provided then defaults to 162."""
Expand Down Expand Up @@ -323,7 +323,7 @@ def test(self) -> None:

# Verify SNMP host details.
if not (snmp_hosts := get_value(self.instance_commands[0].json_output, "hosts")):
self.result.is_failure("SNMP is not configured.")
self.result.is_failure("No SNMP host is configured.")
return

for host in self.inputs.notification_hosts:
Expand Down
2 changes: 1 addition & 1 deletion tests/units/anta_tests/test_snmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
{"hostname": "192.168.1.101", "vrf": "default", "notification_type": "trap", "version": "v2c", "udp_port": 162, "community_string": "public"},
]
},
"expected": {"result": "failure", "messages": ["SNMP is not configured."]},
"expected": {"result": "failure", "messages": ["No SNMP host is configured."]},
},
{
"name": "failure-details-not-found",
Expand Down

0 comments on commit da8ba27

Please sign in to comment.