mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-30 22:31:25 -07:00
code cleanup for --diff
and --check
modes (#33665)
* code cleanup for `--diff` and `--check` modes * fixes UT to remove exec_command
This commit is contained in:
parent
4d67cdd1f7
commit
012a96dabd
9 changed files with 68 additions and 55 deletions
|
@ -32,9 +32,6 @@ class TestIosxrNetconfModule(TestIosxrModule):
|
|||
def setUp(self):
|
||||
super(TestIosxrNetconfModule, self).setUp()
|
||||
|
||||
self.mock_exec_command = patch('ansible.modules.network.iosxr.iosxr_netconf.exec_command')
|
||||
self.exec_command = self.mock_exec_command.start()
|
||||
|
||||
self.mock_get_config = patch('ansible.modules.network.iosxr.iosxr_netconf.get_config')
|
||||
self.get_config = self.mock_get_config.start()
|
||||
|
||||
|
@ -43,7 +40,6 @@ class TestIosxrNetconfModule(TestIosxrModule):
|
|||
|
||||
def tearDown(self):
|
||||
super(TestIosxrNetconfModule, self).tearDown()
|
||||
self.mock_exec_command.stop()
|
||||
self.mock_get_config.stop()
|
||||
self.mock_load_config.stop()
|
||||
|
||||
|
@ -54,14 +50,14 @@ class TestIosxrNetconfModule(TestIosxrModule):
|
|||
!
|
||||
ssh server netconf vrf default
|
||||
'''
|
||||
self.exec_command.return_value = 0, '', None
|
||||
self.load_config.return_value = 'dummy diff'
|
||||
set_module_args(dict(netconf_port=830, netconf_vrf='default', state='absent'))
|
||||
result = self.execute_module(changed=True)
|
||||
self.assertEqual(result['commands'], ['no netconf-yang agent ssh', 'no ssh server netconf port 830', 'no ssh server netconf vrf default'])
|
||||
|
||||
def test_iosxr_enable_netconf_service(self):
|
||||
self.get_config.return_value = ''
|
||||
self.exec_command.return_value = 0, '', None
|
||||
self.load_config.return_value = 'dummy diff'
|
||||
set_module_args(dict(netconf_port=830, netconf_vrf='default', state='present'))
|
||||
result = self.execute_module(changed=True)
|
||||
self.assertEqual(result['commands'], ['netconf-yang agent ssh', 'ssh server netconf port 830', 'ssh server netconf vrf default'])
|
||||
|
@ -73,7 +69,7 @@ class TestIosxrNetconfModule(TestIosxrModule):
|
|||
!
|
||||
ssh server netconf vrf default
|
||||
'''
|
||||
self.exec_command.return_value = 0, '', None
|
||||
self.load_config.return_value = 'dummy diff'
|
||||
set_module_args(dict(netconf_port=9000, state='present'))
|
||||
result = self.execute_module(changed=True)
|
||||
self.assertEqual(result['commands'], ['ssh server netconf port 9000'])
|
||||
|
@ -85,7 +81,7 @@ class TestIosxrNetconfModule(TestIosxrModule):
|
|||
!
|
||||
ssh server netconf vrf default
|
||||
'''
|
||||
self.exec_command.return_value = 0, '', None
|
||||
self.load_config.return_value = 'dummy diff'
|
||||
set_module_args(dict(netconf_vrf='new_default', state='present'))
|
||||
result = self.execute_module(changed=True)
|
||||
self.assertEqual(result['commands'], ['ssh server netconf vrf new_default'])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue