File: test_iosxe.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 (41 lines) | stat: -rw-r--r-- 1,321 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
35
36
37
38
39
40
41
import unittest
from ncclient.devices.iosxe import *
from ncclient.xml_ import new_ele
from ncclient.xml_ import qualify
from ncclient.xml_ import validated_element


CFG_BROKEN = """
<config>
  <native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
    <hostname>tl-einarnn-c8kv</hostname>
  </native>
</config>
"""


class TestIosxeDevice(unittest.TestCase):
    
    def setUp(self):
        self.obj = IosxeDeviceHandler({'name': 'iosxe'})

    def test_add_additional_operations(self):
        expected = {'save_config': SaveConfig}
        self.assertDictEqual(expected, self.obj.add_additional_operations())

    def test_add_additional_ssh_connect_params(self):
        expected = dict()
        expected["unknown_host_cb"] = iosxe_unknown_host_cb
        actual = dict()
        self.obj.add_additional_ssh_connect_params(actual)
        self.assertDictEqual(expected, actual)

    def test_csr_unknown_host_cb(self):
        self.assertTrue(iosxe_unknown_host_cb('host', 'fingerprint'))

    def test_iosxe_transform_edit_config(self):
        node = new_ele("edit-config")
        node.append(validated_element(CFG_BROKEN, ("config", qualify("config"))))
        node = self.obj.transform_edit_config(node)
        config_nodes = node.findall('./config')
        self.assertTrue(len(config_nodes) == 0)