From f6be12b5d889ae04b500a23fa254665b3bf4cca5 Mon Sep 17 00:00:00 2001 From: Tim Rupp Date: Fri, 1 Dec 2017 19:45:37 -0800 Subject: [PATCH] Adds various fixes for bigip_config tests (#33470) There were upstream changes that were incompatible with the downstream code. This fixes those. --- test/units/modules/network/f5/test_bigip_config.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/units/modules/network/f5/test_bigip_config.py b/test/units/modules/network/f5/test_bigip_config.py index 9cb02c7260..92984dd33c 100644 --- a/test/units/modules/network/f5/test_bigip_config.py +++ b/test/units/modules/network/f5/test_bigip_config.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_config import Parameters from library.bigip_config import ModuleManager from library.bigip_config 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_config import Parameters from ansible.modules.network.f5.bigip_config import ModuleManager from ansible.modules.network.f5.bigip_config 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") @@ -39,12 +41,19 @@ fixture_data = {} def load_fixture(name): path = os.path.join(fixture_path, name) + + if path in fixture_data: + return fixture_data[path] + with open(path) as f: data = f.read() + try: data = json.loads(data) except Exception: pass + + fixture_data[path] = data return data