mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-30 22:31:25 -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.iosxr import iosxr_netconf
|
||||
from .iosxr_module import TestIosxrModule, set_module_args
|
||||
from units.modules.utils import set_module_args
|
||||
from .iosxr_module import TestIosxrModule
|
||||
|
||||
|
||||
class TestIosxrNetconfModule(TestIosxrModule):
|
||||
|
@ -29,6 +30,8 @@ class TestIosxrNetconfModule(TestIosxrModule):
|
|||
module = iosxr_netconf
|
||||
|
||||
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()
|
||||
|
||||
|
@ -39,6 +42,7 @@ class TestIosxrNetconfModule(TestIosxrModule):
|
|||
self.load_config = self.mock_load_config.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestIosxrNetconfModule, self).tearDown()
|
||||
self.mock_exec_command.stop()
|
||||
self.mock_get_config.stop()
|
||||
self.mock_load_config.stop()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue