File: test_helpers.py

package info (click to toggle)
python-ezsnmp 1.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,256 kB
  • sloc: cpp: 3,746; python: 1,987; javascript: 1,110; makefile: 17; sh: 12
file content (57 lines) | stat: -rw-r--r-- 1,567 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from __future__ import unicode_literals

from ezsnmp.helpers import normalize_oid


def test_normalize_oid_just_iso():
    oid, oid_index = normalize_oid("oid")
    assert oid == "oid"
    assert oid_index == ""


def test_normalize_oid_just_period():
    oid, oid_index = normalize_oid(".")
    assert oid == "."
    assert oid_index == ""


def test_normalize_oid_regular():
    oid, oid_index = normalize_oid("sysContact.0")
    assert oid == "sysContact"
    assert oid_index == "0"


def test_normalize_oid_regular_2():
    oid, oid_index = normalize_oid("SNMPv2::mib-2.17.7.1.4.3.1.2.300")
    assert oid == "SNMPv2::mib-2"
    assert oid_index == "17.7.1.4.3.1.2.300"


def test_normalize_oid_regular_3():
    oid, oid_index = normalize_oid("nsCacheTimeout.1.3.6.1.2.1.2")
    assert oid == "nsCacheTimeout"
    assert oid_index == "1.3.6.1.2.1.2"


def test_normalize_oid_regular_4():
    oid, oid_index = normalize_oid("iso.3.6.1.2.1.31.1.1.1.1.5035")
    assert oid == "iso"
    assert oid_index == "3.6.1.2.1.31.1.1.1.1.5035"


def test_normalize_oid_numeric():
    oid, oid_index = normalize_oid(".1.3.6.1.2.1.1.1.0")
    assert oid == ".1.3.6.1.2.1.1.1.0"
    assert oid_index == ""


def test_normalize_oid_full_qualified():
    oid, oid_index = normalize_oid(".iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0")
    assert oid == ".iso.org.dod.internet.mgmt.mib-2.system.sysDescr"
    assert oid_index == "0"


def test_normalize_oid_with_index():
    oid, oid_index = normalize_oid("abc", "def")
    assert oid == "abc"
    assert oid_index == "def"