mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -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
|
@ -20,11 +20,10 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import json
|
||||
|
||||
from ansible.compat.tests.mock import patch
|
||||
from ansible.modules.network.ovs import openvswitch_bridge
|
||||
from .ovs_module import TestOpenVSwitchModule, load_fixture, set_module_args
|
||||
from units.modules.utils import set_module_args
|
||||
from .ovs_module import TestOpenVSwitchModule, load_fixture
|
||||
|
||||
test_name_side_effect_matrix = {
|
||||
'test_openvswitch_bridge_absent_idempotent': [
|
||||
|
@ -86,6 +85,8 @@ class TestOpenVSwitchBridgeModule(TestOpenVSwitchModule):
|
|||
module = openvswitch_bridge
|
||||
|
||||
def setUp(self):
|
||||
super(TestOpenVSwitchBridgeModule, self).setUp()
|
||||
|
||||
self.mock_run_command = (
|
||||
patch('ansible.module_utils.basic.AnsibleModule.run_command'))
|
||||
self.run_command = self.mock_run_command.start()
|
||||
|
@ -94,6 +95,8 @@ class TestOpenVSwitchBridgeModule(TestOpenVSwitchModule):
|
|||
self.get_bin_path = self.mock_get_bin_path.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestOpenVSwitchBridgeModule, self).tearDown()
|
||||
|
||||
self.mock_run_command.stop()
|
||||
self.mock_get_bin_path.stop()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue