diff options
author | Anil Kumar Muraleedharan <amuraleedhar@lenovo.com> | 2018-07-18 18:17:08 +0200 |
---|---|---|
committer | Nathaniel Case <this.is@nathanielca.se> | 2018-07-18 18:17:08 +0200 |
commit | 0897e79bd1f65398330af3d0fd7216f595974c12 (patch) | |
tree | e99beaf8f97233f74ed0461883089fa409f6e5f4 /test | |
parent | VMware: blacklist custom fields in vmware_inventory.py (#36877) (diff) | |
download | ansible-0897e79bd1f65398330af3d0fd7216f595974c12.tar.xz ansible-0897e79bd1f65398330af3d0fd7216f595974c12.zip |
Persistence connection for cnos_vlan (#42500)
* Changing Lenovo Inc to Lenovo and update License file to be consistent.
* Changing cnos_vlan from paramiko to persistence connection of Ansible. Also talking care of CLI changes in CNOS commands with backward compatibility.
* Fixing Validation issues
* Trailing lines removal
* Review comments of Gundalow are getting addressed. He mentioned only at one place for cnos.py. But I have covered the entire file.
* Changes to incorporate Review comments from Qalthos
* Removing configure terminal command from module code
* Aligning with change in run_cnos_commands method changes
* Editing cliconf for latest CNOS CLIs
Diffstat (limited to 'test')
-rw-r--r-- | test/units/modules/network/cnos/fixtures/cnos_vlan_config.cfg | 21 | ||||
-rw-r--r-- | test/units/modules/network/cnos/test_cnos_vlan.py | 47 |
2 files changed, 68 insertions, 0 deletions
diff --git a/test/units/modules/network/cnos/fixtures/cnos_vlan_config.cfg b/test/units/modules/network/cnos/fixtures/cnos_vlan_config.cfg new file mode 100644 index 0000000000..810f7d8067 --- /dev/null +++ b/test/units/modules/network/cnos/fixtures/cnos_vlan_config.cfg @@ -0,0 +1,21 @@ +VLAN Name Status IPMC FLOOD Ports +======== ================================ ======= ========== =================== +1 default ACTIVE IPv6 + Ethernet1/2(u) + Ethernet1/3(t) + Ethernet1/4(t) + Ethernet1/9(u) + Ethernet1/10(u) + Ethernet1/14(u) + Ethernet1/15(u) + Ethernet1/16(u) + Ethernet1/17(u) +13 anil ACTIVE IPv4,IPv6 + po13(t) + po17(t) + po100(t) + po1003(t) + po1004(t) + Ethernet1/3(t) + Ethernet1/4(t) + diff --git a/test/units/modules/network/cnos/test_cnos_vlan.py b/test/units/modules/network/cnos/test_cnos_vlan.py new file mode 100644 index 0000000000..97318e4fc5 --- /dev/null +++ b/test/units/modules/network/cnos/test_cnos_vlan.py @@ -0,0 +1,47 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import json +from ansible.compat.tests.mock import patch +from ansible.modules.network.cnos import cnos_vlan +from units.modules.utils import set_module_args +from .cnos_module import TestCnosModule, load_fixture + + +class TestCnosVlanModule(TestCnosModule): + + module = cnos_vlan + + def setUp(self): + super(TestCnosVlanModule, self).setUp() + + self.mock_run_cnos_commands = patch('ansible.module_utils.network.cnos.cnos.run_cnos_commands') + self.run_cnos_commands = self.mock_run_cnos_commands.start() + + def tearDown(self): + super(TestCnosVlanModule, self).tearDown() + self.mock_run_cnos_commands.stop() + + def load_fixtures(self, commands=None, transport='cli'): + self.run_cnos_commands.return_value = [load_fixture('cnos_vlan_config.cfg')] + + def test_cnos_vlan_create(self): + set_module_args({'username': 'admin', 'password': 'pass', + 'host': '10.241.107.39', 'deviceType': 'g8272_cnos', + 'outputfile': 'test.log', 'vlanArg1': '13', + 'vlanArg2': 'name', 'vlanArg3': 'anil'}) + result = self.execute_module(changed=True) + file = open('Anil.txt', "a") + file.write(str(result)) + file.close() + expected_result = 'VLAN configuration is accomplished' + self.assertEqual(result['msg'], expected_result) + + def test_cnos_vlan_state(self): + set_module_args({'username': 'admin', 'password': 'pass', + 'host': '10.241.107.39', 'deviceType': 'g8272_cnos', + 'outputfile': 'test.log', 'vlanArg1': '13', + 'vlanArg2': 'state', 'vlanArg3': 'active'}) + result = self.execute_module(changed=True) + expected_result = 'VLAN configuration is accomplished' + self.assertEqual(result['msg'], expected_result) |