|
|
|
@ -16,9 +16,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
|
|
|
|
|
from ansible.module_utils.f5_utils import F5ModuleError
|
|
|
|
|
|
|
|
|
@ -27,12 +26,14 @@ try:
|
|
|
|
|
from library.bigip_device_connectivity import ModuleManager
|
|
|
|
|
from library.bigip_device_connectivity 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_device_connectivity import Parameters
|
|
|
|
|
from ansible.modules.network.f5.bigip_device_connectivity import ModuleManager
|
|
|
|
|
from ansible.modules.network.f5.bigip_device_connectivity 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")
|
|
|
|
|
|
|
|
|
@ -40,19 +41,21 @@ 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)
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|