| 1 |
__author__ = "Nitin Kumar, Rick Sherman" |
| 2 |
__credits__ = "Jeremy Schulman" |
| 3 |
|
| 4 |
import unittest |
| 5 |
import nose2 |
| 6 |
|
| 7 |
from jnpr.junos import Device |
| 8 |
from jnpr.junos.utils.util import Util |
| 9 |
|
| 10 |
from unittest.mock import patch |
| 11 |
|
| 12 |
|
| 13 |
class TestUtil(unittest.TestCase): |
| 14 |
@patch("ncclient.manager.connect") |
| 15 |
def setUp(self, mock_connect): |
| 16 |
self.dev = Device( |
| 17 |
host="1.1.1.1", user="nitin", password="password123", gather_facts=False |
| 18 |
) |
| 19 |
self.dev.open() |
| 20 |
self.util = Util(self.dev) |
| 21 |
|
| 22 |
def test_repr(self): |
| 23 |
self.assertEqual(repr(self.util), "jnpr.junos.utils.Util(1.1.1.1)") |
| 24 |
|
| 25 |
def test_dev_setter_exception(self): |
| 26 |
def mod_dev(): |
| 27 |
self.util.dev = "abc" |
| 28 |
|
| 29 |
self.assertRaises(RuntimeError, mod_dev) |
| 30 |
|
| 31 |
def test_rpc_setter_exception(self): |
| 32 |
def mod_rpc(): |
| 33 |
self.util.rpc = "abc" |
| 34 |
|
| 35 |
self.assertRaises(RuntimeError, mod_rpc) |