From 07c9c28a06fe7a7f22803b2ff8f643da9bf045bb Mon Sep 17 00:00:00 2001 From: Tim Rupp Date: Sat, 2 Dec 2017 21:17:53 -0800 Subject: [PATCH] Fixes for unit tests (#33498) upstream unit tests broke downstream code. this rectifies that. --- .../units/modules/network/f5/test_bigip_snat_pool.py | 12 ++++-------- test/units/modules/network/f5/test_bigip_snmp.py | 6 ++++-- .../units/modules/network/f5/test_bigip_snmp_trap.py | 7 +++++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/test/units/modules/network/f5/test_bigip_snat_pool.py b/test/units/modules/network/f5/test_bigip_snat_pool.py index 6f57818780..41e62a7956 100644 --- a/test/units/modules/network/f5/test_bigip_snat_pool.py +++ b/test/units/modules/network/f5/test_bigip_snat_pool.py @@ -15,9 +15,8 @@ if sys.version_info < (2, 7): raise SkipTest("F5 Ansible modules require Python >= 2.7") from ansible.compat.tests import unittest -from ansible.compat.tests.mock import patch, Mock -from ansible.module_utils import basic -from ansible.module_utils._text import to_bytes +from ansible.compat.tests.mock import Mock +from ansible.compat.tests.mock import patch from ansible.module_utils.f5_utils import AnsibleF5Client try: @@ -25,12 +24,14 @@ try: from library.bigip_snat_pool import ModuleManager from library.bigip_snat_pool import ArgumentSpec from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError + from test.unit.modules.utils import set_module_args except ImportError: try: from ansible.modules.network.f5.bigip_snat_pool import Parameters from ansible.modules.network.f5.bigip_snat_pool import ModuleManager from ansible.modules.network.f5.bigip_snat_pool import ArgumentSpec from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError + from units.modules.utils import set_module_args except ImportError: raise SkipTest("F5 Ansible modules require the f5-sdk Python library") @@ -38,11 +39,6 @@ fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') fixture_data = {} -def set_module_args(args): - args = json.dumps({'ANSIBLE_MODULE_ARGS': args}) - basic._ANSIBLE_ARGS = to_bytes(args) - - def load_fixture(name): path = os.path.join(fixture_path, name) diff --git a/test/units/modules/network/f5/test_bigip_snmp.py b/test/units/modules/network/f5/test_bigip_snmp.py index 05fdda8a50..6d5c500822 100644 --- a/test/units/modules/network/f5/test_bigip_snmp.py +++ b/test/units/modules/network/f5/test_bigip_snmp.py @@ -15,21 +15,23 @@ if sys.version_info < (2, 7): raise SkipTest("F5 Ansible modules require Python >= 2.7") from ansible.compat.tests import unittest -from ansible.compat.tests.mock import patch, Mock +from ansible.compat.tests.mock import Mock +from ansible.compat.tests.mock import patch from ansible.module_utils.f5_utils import AnsibleF5Client -from units.modules.utils import set_module_args try: from library.bigip_snmp import Parameters from library.bigip_snmp import ModuleManager from library.bigip_snmp import ArgumentSpec from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError + from test.unit.modules.utils import set_module_args except ImportError: try: from ansible.modules.network.f5.bigip_snmp import Parameters from ansible.modules.network.f5.bigip_snmp import ModuleManager from ansible.modules.network.f5.bigip_snmp import ArgumentSpec from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError + from units.modules.utils import set_module_args except ImportError: raise SkipTest("F5 Ansible modules require the f5-sdk Python library") diff --git a/test/units/modules/network/f5/test_bigip_snmp_trap.py b/test/units/modules/network/f5/test_bigip_snmp_trap.py index 9b7a011ac2..de4a875a9d 100644 --- a/test/units/modules/network/f5/test_bigip_snmp_trap.py +++ b/test/units/modules/network/f5/test_bigip_snmp_trap.py @@ -15,9 +15,10 @@ if sys.version_info < (2, 7): raise SkipTest("F5 Ansible modules require Python >= 2.7") from ansible.compat.tests import unittest -from ansible.compat.tests.mock import patch, DEFAULT, Mock +from ansible.compat.tests.mock import Mock +from ansible.compat.tests.mock import patch +from ansible.compat.tests.mock import DEFAULT from ansible.module_utils.f5_utils import AnsibleF5Client -from units.modules.utils import set_module_args try: from library.bigip_snmp_trap import NetworkedParameters @@ -27,6 +28,7 @@ try: from library.bigip_snmp_trap import NonNetworkedManager from library.bigip_snmp_trap import ArgumentSpec from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError + from test.unit.modules.utils import set_module_args except ImportError: try: from ansible.modules.network.f5.bigip_snmp_trap import NetworkedParameters @@ -36,6 +38,7 @@ except ImportError: from ansible.modules.network.f5.bigip_snmp_trap import NonNetworkedManager from ansible.modules.network.f5.bigip_snmp_trap import ArgumentSpec from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError + from units.modules.utils import set_module_args except ImportError: raise SkipTest("F5 Ansible modules require the f5-sdk Python library")