From 38844194aefed81b7d15a23ef2c9e3a1db7bf462 Mon Sep 17 00:00:00 2001 From: Tim Rupp Date: Mon, 29 Oct 2018 12:43:56 -0700 Subject: [PATCH] Fixes bigiq unit tests for ansible 2.8 (#47771) fixes the unit tests for bigiq in ansible 2.8 because changes broke them --- .../f5/test_bigiq_application_fasthttp.py | 22 +++++++++++-------- .../f5/test_bigiq_application_fastl4_tcp.py | 22 +++++++++++-------- .../f5/test_bigiq_application_fastl4_udp.py | 22 +++++++++++-------- .../network/f5/test_bigiq_application_http.py | 22 +++++++++++-------- .../test_bigiq_application_https_offload.py | 22 +++++++++++-------- .../f5/test_bigiq_application_https_waf.py | 22 +++++++++++-------- 6 files changed, 78 insertions(+), 54 deletions(-) diff --git a/test/units/modules/network/f5/test_bigiq_application_fasthttp.py b/test/units/modules/network/f5/test_bigiq_application_fasthttp.py index bbee5b05574..5c67e435c92 100644 --- a/test/units/modules/network/f5/test_bigiq_application_fasthttp.py +++ b/test/units/modules/network/f5/test_bigiq_application_fasthttp.py @@ -8,16 +8,12 @@ __metaclass__ = type import os import json -import pytest import sys 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 +21,25 @@ try: from library.modules.bigiq_application_fasthttp import ModuleParameters from library.modules.bigiq_application_fasthttp import ModuleManager from library.modules.bigiq_application_fasthttp 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.bigiq_application_fasthttp import ApiParameters from ansible.modules.network.f5.bigiq_application_fasthttp import ModuleParameters from ansible.modules.network.f5.bigiq_application_fasthttp import ModuleManager from ansible.modules.network.f5.bigiq_application_fasthttp 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") diff --git a/test/units/modules/network/f5/test_bigiq_application_fastl4_tcp.py b/test/units/modules/network/f5/test_bigiq_application_fastl4_tcp.py index 316d1c8ede3..d34db62f6aa 100644 --- a/test/units/modules/network/f5/test_bigiq_application_fastl4_tcp.py +++ b/test/units/modules/network/f5/test_bigiq_application_fastl4_tcp.py @@ -8,16 +8,12 @@ __metaclass__ = type import os import json -import pytest import sys 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 +21,25 @@ try: from library.modules.bigiq_application_fastl4_tcp import ModuleParameters from library.modules.bigiq_application_fastl4_tcp import ModuleManager from library.modules.bigiq_application_fastl4_tcp 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.bigiq_application_fastl4_tcp import ApiParameters from ansible.modules.network.f5.bigiq_application_fastl4_tcp import ModuleParameters from ansible.modules.network.f5.bigiq_application_fastl4_tcp import ModuleManager from ansible.modules.network.f5.bigiq_application_fastl4_tcp 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") diff --git a/test/units/modules/network/f5/test_bigiq_application_fastl4_udp.py b/test/units/modules/network/f5/test_bigiq_application_fastl4_udp.py index 4bb1c5053af..ab5b4787991 100644 --- a/test/units/modules/network/f5/test_bigiq_application_fastl4_udp.py +++ b/test/units/modules/network/f5/test_bigiq_application_fastl4_udp.py @@ -8,16 +8,12 @@ __metaclass__ = type import os import json -import pytest import sys 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 +21,25 @@ try: from library.modules.bigiq_application_fastl4_udp import ModuleParameters from library.modules.bigiq_application_fastl4_udp import ModuleManager from library.modules.bigiq_application_fastl4_udp 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.bigiq_application_fastl4_udp import ApiParameters from ansible.modules.network.f5.bigiq_application_fastl4_udp import ModuleParameters from ansible.modules.network.f5.bigiq_application_fastl4_udp import ModuleManager from ansible.modules.network.f5.bigiq_application_fastl4_udp 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") diff --git a/test/units/modules/network/f5/test_bigiq_application_http.py b/test/units/modules/network/f5/test_bigiq_application_http.py index df01ff45043..4ee62753cff 100644 --- a/test/units/modules/network/f5/test_bigiq_application_http.py +++ b/test/units/modules/network/f5/test_bigiq_application_http.py @@ -8,16 +8,12 @@ __metaclass__ = type import os import json -import pytest import sys 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 +21,25 @@ try: from library.modules.bigiq_application_http import ModuleParameters from library.modules.bigiq_application_http import ModuleManager from library.modules.bigiq_application_http 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.bigiq_application_http import ApiParameters from ansible.modules.network.f5.bigiq_application_http import ModuleParameters from ansible.modules.network.f5.bigiq_application_http import ModuleManager from ansible.modules.network.f5.bigiq_application_http 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") diff --git a/test/units/modules/network/f5/test_bigiq_application_https_offload.py b/test/units/modules/network/f5/test_bigiq_application_https_offload.py index 928799f1678..d55fbc44f93 100644 --- a/test/units/modules/network/f5/test_bigiq_application_https_offload.py +++ b/test/units/modules/network/f5/test_bigiq_application_https_offload.py @@ -8,16 +8,12 @@ __metaclass__ = type import os import json -import pytest import sys 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 +21,25 @@ try: from library.modules.bigiq_application_https_offload import ModuleParameters from library.modules.bigiq_application_https_offload import ModuleManager from library.modules.bigiq_application_https_offload 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.bigiq_application_https_offload import ApiParameters from ansible.modules.network.f5.bigiq_application_https_offload import ModuleParameters from ansible.modules.network.f5.bigiq_application_https_offload import ModuleManager from ansible.modules.network.f5.bigiq_application_https_offload 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") diff --git a/test/units/modules/network/f5/test_bigiq_application_https_waf.py b/test/units/modules/network/f5/test_bigiq_application_https_waf.py index 2245cd63206..3810d595594 100644 --- a/test/units/modules/network/f5/test_bigiq_application_https_waf.py +++ b/test/units/modules/network/f5/test_bigiq_application_https_waf.py @@ -8,16 +8,12 @@ __metaclass__ = type import os import json -import pytest import sys 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 +21,25 @@ try: from library.modules.bigiq_application_https_waf import ModuleParameters from library.modules.bigiq_application_https_waf import ModuleManager from library.modules.bigiq_application_https_waf 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.bigiq_application_https_waf import ApiParameters from ansible.modules.network.f5.bigiq_application_https_waf import ModuleParameters from ansible.modules.network.f5.bigiq_application_https_waf import ModuleManager from ansible.modules.network.f5.bigiq_application_https_waf 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")