Convert nxos_vlan to DI module (#31866)

* Convert nxos_vlan to DI

* fix conflict

* push fix for qalthos's comment

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
Trishna Guha 2017-12-21 14:08:33 +05:30 committed by GitHub
parent 8b15b93d01
commit 60f3649ebd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 483 additions and 243 deletions

View file

@ -42,10 +42,16 @@ class TestNxosVlanModule(TestNxosModule):
self.mock_get_config = patch('ansible.modules.network.nxos.nxos_vlan.get_config')
self.get_config = self.mock_get_config.start()
self.mock_get_capabilities = patch('ansible.modules.network.nxos.nxos_vlan.get_capabilities')
self.get_capabilities = self.mock_get_capabilities.start()
self.get_capabilities.return_value = {'network_api': 'cliconf'}
def tearDown(self):
super(TestNxosVlanModule, self).tearDown()
self.mock_run_commands.stop()
self.mock_load_config.stop()
self.mock_get_config.stop()
self.mock_get_capabilities.stop()
def load_fixtures(self, commands=None, device=''):
def load_from_file(*args, **kwargs):
@ -64,11 +70,11 @@ class TestNxosVlanModule(TestNxosModule):
self.run_commands.side_effect = load_from_file
self.load_config.return_value = None
self.get_config.return_value = load_fixture('nxos_vlan', 'config.cfg')
def test_nxos_vlan_range(self):
set_module_args(dict(vlan_range='6-10'))
result = self.execute_module(changed=True)
self.assertEqual(result['commands'], ['vlan 6', 'vlan 7', 'vlan 8', 'vlan 9', 'vlan 10'])
self.execute_module(changed=True, commands=['vlan 6', 'vlan 7', 'vlan 8', 'vlan 9', 'vlan 10'])
def test_nxos_vlan_range_absent(self):
set_module_args(dict(vlan_range='1-5', state='absent'))
@ -78,7 +84,7 @@ class TestNxosVlanModule(TestNxosModule):
def test_nxos_vlan_id(self):
set_module_args(dict(vlan_id='15', state='present'))
result = self.execute_module(changed=True)
self.assertEqual(result['commands'], ['vlan 15', 'exit'])
self.assertEqual(result['commands'], ['vlan 15', 'state active', 'no shutdown', 'exit'])
def test_nxos_vlan_id_absent(self):
set_module_args(dict(vlan_id='1', state='absent'))
@ -88,7 +94,7 @@ class TestNxosVlanModule(TestNxosModule):
def test_nxos_vlan_named_vlan(self):
set_module_args(dict(vlan_id='15', name='WEB'))
result = self.execute_module(changed=True)
self.assertEqual(result['commands'], ['vlan 15', 'name WEB', 'exit'])
self.assertEqual(result['commands'], ['vlan 15', 'name WEB', 'state active', 'no shutdown', 'exit'])
def test_nxos_vlan_shut_down(self):
set_module_args(dict(vlan_id='1', admin_state='down'))