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
parent 71a6dcdf3e
commit a5c9726502
154 changed files with 671 additions and 1113 deletions

View file

@ -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.ios import ios_system
from .ios_module import TestIosModule, load_fixture, set_module_args
from units.modules.utils import set_module_args
from .ios_module import TestIosModule, load_fixture
class TestIosSystemModule(TestIosModule):
@ -32,6 +31,8 @@ class TestIosSystemModule(TestIosModule):
module = ios_system
def setUp(self):
super(TestIosSystemModule, self).setUp()
self.mock_get_config = patch('ansible.modules.network.ios.ios_system.get_config')
self.get_config = self.mock_get_config.start()
@ -39,6 +40,7 @@ class TestIosSystemModule(TestIosModule):
self.load_config = self.mock_load_config.start()
def tearDown(self):
super(TestIosSystemModule, self).tearDown()
self.mock_get_config.stop()
self.mock_load_config.stop()