mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-11 03:31:29 -07:00
Fixing eos_config save option. Was removed when deprecated. Fixing ot… (#35628)
* Fixing eos_config save option. Was removed when deprecated. Fixing other deprecation documentation. Adding unit tests. * Fixing removed_in_version for force.
This commit is contained in:
parent
75a285ded9
commit
663c410da4
2 changed files with 58 additions and 17 deletions
|
@ -36,6 +36,8 @@ class TestEosConfigModule(TestEosModule):
|
|||
|
||||
self.mock_load_config = patch('ansible.modules.network.eos.eos_config.load_config')
|
||||
self.load_config = self.mock_load_config.start()
|
||||
self.mock_run_commands = patch('ansible.modules.network.eos.eos_config.run_commands')
|
||||
self.run_commands = self.mock_run_commands.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestEosConfigModule, self).tearDown()
|
||||
|
@ -153,3 +155,30 @@ class TestEosConfigModule(TestEosModule):
|
|||
result = self.execute_module(changed=True)
|
||||
|
||||
mock_run_commands.stop()
|
||||
|
||||
def test_eos_config_save_changed_true(self):
|
||||
commands = ['hostname foo', 'interface GigabitEthernet0/0', 'no ip address']
|
||||
set_module_args(dict(save_when='changed', lines=commands))
|
||||
self.execute_module(changed=True)
|
||||
self.assertEqual(self.run_commands.call_count, 1)
|
||||
self.assertEqual(self.get_config.call_count, 1)
|
||||
self.assertEqual(self.load_config.call_count, 1)
|
||||
args = self.run_commands.call_args[0][1][0]['command']
|
||||
self.assertIn('copy running-config startup-config', args)
|
||||
|
||||
def test_eos_config_save_changed_false(self):
|
||||
set_module_args(dict(save_when='changed'))
|
||||
self.execute_module(changed=False)
|
||||
self.assertEqual(self.run_commands.call_count, 0)
|
||||
self.assertEqual(self.get_config.call_count, 0)
|
||||
self.assertEqual(self.load_config.call_count, 0)
|
||||
|
||||
def test_eos_config_save(self):
|
||||
self.run_commands.return_value = "hostname foo"
|
||||
set_module_args(dict(save=True))
|
||||
self.execute_module(changed=True)
|
||||
self.assertEqual(self.run_commands.call_count, 1)
|
||||
self.assertEqual(self.get_config.call_count, 0)
|
||||
self.assertEqual(self.load_config.call_count, 0)
|
||||
args = self.run_commands.call_args[0][1][0]['command']
|
||||
self.assertIn('copy running-config startup-config', args)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue