File: test_table.py

package info (click to toggle)
junos-eznc 2.7.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,496 kB
  • sloc: xml: 50,219; python: 20,961; makefile: 155; sh: 44; ruby: 2
file content (34 lines) | stat: -rw-r--r-- 795 bytes parent folder | download | duplicates (2)
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
__author__ = "rsherman, vnitinv"

try:
    import unittest2 as unittest
except ImportError:
    import unittest

from jnpr.junos.op.routes import RouteTable
import json


class __TestTable(object):
    @classmethod
    def setUpClass(self):
        from jnpr.junos import Device

        self.dev = Device(host="xxxx", user="jenkins", password="password")
        self.dev.open()

    @classmethod
    def tearDownClass(self):
        self.dev.close()

    def test_table_union(self):
        tbl = RouteTable(self.dev)
        tbl.get()
        self.assertEqual(tbl[0].via, "em0.0")

    def test_table_json(self):
        tbl = RouteTable(self.dev)
        tbl.get("10.48.21.71")
        self.assertEqual(
            json.loads(tbl.to_json())["10.48.21.71/32"]["protocol"], "Local"
        )