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

@ -25,7 +25,8 @@ if sys.version_info[:2] != (2, 6):
import requests
from .netscaler_module import TestModule, nitro_base_patcher, set_module_args
from units.modules.utils import set_module_args
from .netscaler_module import TestModule, nitro_base_patcher
class TestNetscalerServiceModule(TestModule):
@ -65,12 +66,14 @@ class TestNetscalerServiceModule(TestModule):
))
def setUp(self):
super(TestNetscalerServiceModule, self).setUp()
self.nitro_base_patcher.start()
self.nitro_specific_patcher.start()
# Setup minimal required arguments to pass AnsibleModule argument parsing
def tearDown(self):
super(TestNetscalerServiceModule, self).tearDown()
self.nitro_base_patcher.stop()
self.nitro_specific_patcher.stop()