Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidRares authored and lextm committed Aug 29, 2024
1 parent 05ebacb commit 4a839c7
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/proto/test_network_address.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import pytest
from pyasn1.type.namedtype import NamedType

from pysnmp.proto.rfc1155 import NetworkAddress, IpAddress, TypeCoercionHackMixIn


def test_clone_none():
n = NetworkAddress()

assert n.clone().prettyPrint() == n.prettyPrint()


def test_clone_NetworkAddress():
n = NetworkAddress()

assert n.clone(n.clone("10.10.10.10")).getName() == "internet"


def test_clone_IpAddress():
ip = IpAddress("10.10.10.10")
n = NetworkAddress()

assert n.clone(ip).getName() == "internet"


def test_clone_string():
n = NetworkAddress()

assert n.clone("10.10.10.10").getName() == "internet"


def test_verifyComponent_normal():
t = TypeCoercionHackMixIn()
t._componentType = [NamedType("internet", IpAddress("10.10.10.10"))]

t._verifyComponent(0, IpAddress("10.2.3.4"))


def test_verifyComponent_invalidIdx():
t = TypeCoercionHackMixIn()
t._componentType = [NamedType("internet", IpAddress("10.10.10.10"))]

with pytest.raises(Exception):
t._verifyComponent(1, IpAddress("10.2.3.4"))

0 comments on commit 4a839c7

Please sign in to comment.