mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Fix 'defaults' option in the nxos_config module (#51076)
* Fix 'defaults' option in the nxos_config module Nxos get_config is allways called with the 'all' option. * Fix flag's calculation * Add tests * nxos_config: the 'backup' option take into account the value of 'defaults' option If 'defaults' option is true, the running-config backup is done with the all keyword.
This commit is contained in:
committed by
Trishna Guha
parent
7eab04e975
commit
87a01df6ad
@@ -198,3 +198,27 @@ class TestNxosConfigModule(TestNxosModule):
|
||||
self.assertEqual(self.save_config.call_count, 0)
|
||||
self.assertEqual(self.get_config.call_count, 0)
|
||||
self.assertEqual(self.load_config.call_count, 0)
|
||||
|
||||
def test_nxos_config_defaults_false(self):
|
||||
set_module_args(dict(lines=['hostname localhost'], defaults=False))
|
||||
result = self.execute_module(changed=True)
|
||||
self.assertEqual(self.get_config.call_count, 1)
|
||||
self.assertEqual(self.get_config.call_args[1], dict(flags=[]))
|
||||
|
||||
def test_nxos_config_defaults_true(self):
|
||||
set_module_args(dict(lines=['hostname localhost'], defaults=True))
|
||||
result = self.execute_module(changed=True)
|
||||
self.assertEqual(self.get_config.call_count, 1)
|
||||
self.assertEqual(self.get_config.call_args[1], dict(flags=['all']))
|
||||
|
||||
def test_nxos_config_defaults_false_backup_true(self):
|
||||
set_module_args(dict(lines=['hostname localhost'], defaults=False, backup=True))
|
||||
result = self.execute_module(changed=True)
|
||||
self.assertEqual(self.get_config.call_count, 1)
|
||||
self.assertEqual(self.get_config.call_args[1], dict(flags=[]))
|
||||
|
||||
def test_nxos_config_defaults_true_backup_true(self):
|
||||
set_module_args(dict(lines=['hostname localhost'], defaults=True, backup=True))
|
||||
result = self.execute_module(changed=True)
|
||||
self.assertEqual(self.get_config.call_count, 1)
|
||||
self.assertEqual(self.get_config.call_args[1], dict(flags=['all']))
|
||||
|
||||
Reference in New Issue
Block a user