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:
Pilou 2017-11-17 18:17:07 +01:00 committed by Matt Clay
commit a5c9726502
154 changed files with 671 additions and 1113 deletions

View file

@ -22,8 +22,9 @@ __metaclass__ = type
import json
from ansible.compat.tests.mock import patch
from .enos_module import TestEnosModule, load_fixture, set_module_args
from .enos_module import TestEnosModule, load_fixture
from ansible.modules.network.enos import enos_facts
from units.modules.utils import set_module_args
class TestEnosFacts(TestEnosModule):
@ -31,11 +32,13 @@ class TestEnosFacts(TestEnosModule):
module = enos_facts
def setUp(self):
super(TestEnosFacts, self).setUp()
self.mock_run_commands = patch(
'ansible.modules.network.enos.enos_facts.run_commands')
self.run_commands = self.mock_run_commands.start()
def tearDown(self):
super(TestEnosFacts, self).tearDown()
self.mock_run_commands.stop()
def load_fixtures(self, commands=None):