forked from etingof/pysnmp
-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
05ebacb
commit 4a839c7
Showing
1 changed file
with
44 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,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")) |