mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-03 07:41:30 -07:00
Unit tests: share common code (#31456)
* move set_module_args to units.modules.utils * unit tests: reuse set_module_args * unit tests: mock exit/fail_json in module.utils.ModuleTestCase * unit tests: use module.utils.ModuleTestCase * unit tests: fix 'import shadowed by loop variable'
This commit is contained in:
parent
71a6dcdf3e
commit
a5c9726502
154 changed files with 671 additions and 1113 deletions
|
@ -21,7 +21,8 @@ __metaclass__ = type
|
|||
|
||||
from ansible.compat.tests.mock import patch
|
||||
from ansible.modules.network.junos import junos_netconf
|
||||
from .junos_module import TestJunosModule, set_module_args
|
||||
from units.modules.utils import set_module_args
|
||||
from .junos_module import TestJunosModule
|
||||
|
||||
|
||||
class TestJunosCommandModule(TestJunosModule):
|
||||
|
@ -29,6 +30,8 @@ class TestJunosCommandModule(TestJunosModule):
|
|||
module = junos_netconf
|
||||
|
||||
def setUp(self):
|
||||
super(TestJunosCommandModule, self).setUp()
|
||||
|
||||
self.mock_exec_command = patch('ansible.modules.network.junos.junos_netconf.exec_command')
|
||||
self.exec_command = self.mock_exec_command.start()
|
||||
|
||||
|
@ -42,6 +45,7 @@ class TestJunosCommandModule(TestJunosModule):
|
|||
self.commit_configuration = self.mock_commit_configuration.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestJunosCommandModule, self).tearDown()
|
||||
self.mock_exec_command.stop()
|
||||
self.mock_lock_configuration.stop()
|
||||
self.mock_unlock_configuration.stop()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue