mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
Adding changed option to save_when for aireos (#40681)
* Adding changed option to save_when for aireos * Deprecating save option for aireos_config. * Updating version_added to 2.7 since the PR missed the window for 2.6
This commit is contained in:
committed by
Nathaniel Case
parent
5350d0697f
commit
083ddb9bc2
@@ -42,6 +42,9 @@ class TestCiscoWlcConfigModule(TestCiscoWlcModule):
|
||||
self.mock_run_commands = patch('ansible.modules.network.aireos.aireos_config.run_commands')
|
||||
self.run_commands = self.mock_run_commands.start()
|
||||
|
||||
self.mock_save_config = patch('ansible.modules.network.aireos.aireos_config.save_config')
|
||||
self.save_config = self.mock_save_config.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestCiscoWlcConfigModule, self).tearDown()
|
||||
self.mock_get_config.stop()
|
||||
@@ -70,10 +73,9 @@ class TestCiscoWlcConfigModule(TestCiscoWlcModule):
|
||||
self.assertIn('__backup__', result)
|
||||
|
||||
def test_aireos_config_save(self):
|
||||
self.run_commands.return_value = "sysname foo"
|
||||
set_module_args(dict(save=True))
|
||||
self.execute_module(changed=True)
|
||||
self.assertEqual(self.run_commands.call_count, 1)
|
||||
self.execute_module()
|
||||
self.assertEqual(self.save_config.call_count, 1)
|
||||
self.assertEqual(self.get_config.call_count, 0)
|
||||
self.assertEqual(self.load_config.call_count, 0)
|
||||
|
||||
@@ -103,3 +105,27 @@ class TestCiscoWlcConfigModule(TestCiscoWlcModule):
|
||||
lines = ['sysname router', 'interface create mtc-1 1']
|
||||
set_module_args(dict(lines=lines, match='none'))
|
||||
self.execute_module(changed=True, commands=lines, sort=False)
|
||||
|
||||
def test_nxos_config_save_always(self):
|
||||
args = dict(save_when='always')
|
||||
set_module_args(args)
|
||||
self.execute_module()
|
||||
self.assertEqual(self.save_config.call_count, 1)
|
||||
self.assertEqual(self.get_config.call_count, 0)
|
||||
self.assertEqual(self.load_config.call_count, 0)
|
||||
|
||||
def test_nxos_config_save_changed_true(self):
|
||||
args = dict(save_when='changed', lines=['sysname foo', 'interface create mtc-3 3'])
|
||||
set_module_args(args)
|
||||
self.execute_module(changed=True)
|
||||
self.assertEqual(self.save_config.call_count, 1)
|
||||
self.assertEqual(self.get_config.call_count, 1)
|
||||
self.assertEqual(self.load_config.call_count, 1)
|
||||
|
||||
def test_nxos_config_save_changed_false(self):
|
||||
args = dict(save_when='changed')
|
||||
set_module_args(args)
|
||||
self.execute_module()
|
||||
self.assertEqual(self.save_config.call_count, 0)
|
||||
self.assertEqual(self.get_config.call_count, 0)
|
||||
self.assertEqual(self.load_config.call_count, 0)
|
||||
|
||||
Reference in New Issue
Block a user