1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Adds token cleanup and fixes unit tests (#48493)

This commit is contained in:
Tim Rupp 2018-11-10 14:40:14 -08:00 committed by GitHub
parent 1afbe4d61b
commit 7d11e6e3e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 11 deletions

View file

@ -1102,12 +1102,15 @@ def main():
required_one_of=spec.required_one_of
)
client = F5RestClient(**module.params)
try:
client = F5RestClient(**module.params)
mm = ModuleManager(module=module, client=client)
results = mm.exec_module()
cleanup_tokens(client)
exit_json(module, results, client)
except F5ModuleError as ex:
cleanup_tokens(client)
fail_json(module, ex, client)

View file

@ -15,9 +15,6 @@ from nose.plugins.skip import SkipTest
if sys.version_info < (2, 7):
raise SkipTest("F5 Ansible modules require Python >= 2.7")
from units.compat import unittest
from units.compat.mock import Mock
from units.compat.mock import patch
from ansible.module_utils.basic import AnsibleModule
try:
@ -25,17 +22,25 @@ try:
from library.modules.bigip_firewall_rule import ModuleParameters
from library.modules.bigip_firewall_rule import ModuleManager
from library.modules.bigip_firewall_rule import ArgumentSpec
from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
from test.unit.modules.utils import set_module_args
# In Ansible 2.8, Ansible changed import paths.
from test.units.compat import unittest
from test.units.compat.mock import Mock
from test.units.compat.mock import patch
from test.units.modules.utils import set_module_args
except ImportError:
try:
from ansible.modules.network.f5.bigip_firewall_rule import ApiParameters
from ansible.modules.network.f5.bigip_firewall_rule import ModuleParameters
from ansible.modules.network.f5.bigip_firewall_rule import ModuleManager
from ansible.modules.network.f5.bigip_firewall_rule import ArgumentSpec
from ansible.module_utils.network.f5.common import F5ModuleError
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
# Ansible 2.8 imports
from units.compat import unittest
from units.compat.mock import Mock
from units.compat.mock import patch
from units.modules.utils import set_module_args
except ImportError:
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
@ -100,8 +105,6 @@ class TestParameters(unittest.TestCase):
assert p.logging is True
@patch('ansible.module_utils.f5_utils.AnsibleF5Client._get_mgmt_root',
return_value=True)
class TestManager(unittest.TestCase):
def setUp(self):