Exemple #1
0
def test_oid_from_unresolved_instance(value, expected_tuple):
    # type: (Any, Tuple[int, ...]) -> None
    oid = OID(value)

    with pytest.raises(UnresolvedOID):
        oid.as_tuple()

    object_type = oid.as_object_type()

    # Verify returned ObjectType instance is valid by decoding it.
    mib_view_controller = MibViewController(SnmpEngine().getMibBuilder())
    resolved = object_type.resolveWithMib(mib_view_controller)
    assert OID(resolved).as_tuple() == expected_tuple
Exemple #2
0
def test_oid_mib_symbol(identity, name, prefix):
    # type: (ObjectIdentity, str, tuple) -> None
    if callable(identity):
        identity = identity()

    oid = OID(identity)

    mib_view_controller = MibViewController(SnmpEngine().getMibBuilder())
    oid.resolve(mib_view_controller)

    symbol = oid.get_mib_symbol()
    assert symbol.name == name
    assert symbol.prefix == prefix
Exemple #3
0
def test_oid_parse_valid(value, expected_tuple):
    # type: (Any, Tuple[int, ...]) -> None
    mib_view_controller = MibViewController(SnmpEngine().getMibBuilder())
    if callable(value):
        value = value(mib_view_controller)
    assert OID(value).as_tuple() == expected_tuple