File: test_rpc.py

package info (click to toggle)
python-ncclient 0.6.17-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,448 kB
  • sloc: python: 9,548; xml: 476; makefile: 77; sh: 5
file content (22 lines) | stat: -rw-r--r-- 761 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
import unittest
try:
    from unittest.mock import patch  # Python 3.4 and later
except ImportError:
    from mock import patch
from ncclient import manager
import ncclient.transport
from ncclient.operations.third_party.iosxe.rpc import *


class TestRPC(unittest.TestCase):
    def setUp(self):
        self.device_handler = manager.make_device_handler({'name': 'iosxe'})
    
    @patch('ncclient.operations.third_party.iosxe.rpc.RPC._request')
    def test_saveConfig(self, mock_request):
        mock_request.return_value = 'iosxe'
        expected = 'iosxe'
        session = ncclient.transport.SSHSession(self.device_handler)
        obj = SaveConfig(session, self.device_handler)
        actual = obj.request()
        self.assertEqual(expected, actual)