From f60b8a3abb7020314d5d2f76028e56c80adaa74e Mon Sep 17 00:00:00 2001 From: Tim Rupp Date: Fri, 1 Dec 2017 21:16:11 -0800 Subject: [PATCH] Fixes various things in bigip tests (#33477) an upstream change was introduced that broke downstream code. This path rectifies that error --- .../modules/network/f5/test_bigip_gtm_pool.py | 6 +++-- .../network/f5/test_bigip_gtm_wide_ip.py | 6 +++-- .../modules/network/f5/test_bigip_hostname.py | 6 +++-- .../modules/network/f5/test_bigip_irule.py | 7 ++++-- .../network/f5/test_bigip_partition.py | 24 +++++-------------- .../modules/network/f5/test_bigip_pool.py | 6 +++-- .../modules/network/f5/test_bigip_qkview.py | 6 +++-- .../network/f5/test_bigip_vcmp_guest.py | 13 ++++------ .../modules/network/f5/test_bigip_wait.py | 24 +++++-------------- 9 files changed, 41 insertions(+), 57 deletions(-) diff --git a/test/units/modules/network/f5/test_bigip_gtm_pool.py b/test/units/modules/network/f5/test_bigip_gtm_pool.py index be2d4bb704..11ea873862 100644 --- a/test/units/modules/network/f5/test_bigip_gtm_pool.py +++ b/test/units/modules/network/f5/test_bigip_gtm_pool.py @@ -15,9 +15,9 @@ 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_gtm_pool import Parameters @@ -26,6 +26,7 @@ try: from library.bigip_gtm_pool import UntypedManager from library.bigip_gtm_pool import TypedManager 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_gtm_pool import Parameters @@ -34,6 +35,7 @@ except ImportError: from ansible.modules.network.f5.bigip_gtm_pool import UntypedManager from ansible.modules.network.f5.bigip_gtm_pool import TypedManager 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_gtm_wide_ip.py b/test/units/modules/network/f5/test_bigip_gtm_wide_ip.py index 908c0d12e3..22ae6e63aa 100644 --- a/test/units/modules/network/f5/test_bigip_gtm_wide_ip.py +++ b/test/units/modules/network/f5/test_bigip_gtm_wide_ip.py @@ -16,10 +16,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, Mock +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 -from units.modules.utils import set_module_args try: from library.bigip_gtm_wide_ip import Parameters @@ -28,6 +28,7 @@ try: from library.bigip_gtm_wide_ip import UntypedManager from library.bigip_gtm_wide_ip import TypedManager 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_gtm_wide_ip import Parameters @@ -36,6 +37,7 @@ except ImportError: from ansible.modules.network.f5.bigip_gtm_wide_ip import UntypedManager from ansible.modules.network.f5.bigip_gtm_wide_ip import TypedManager 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_hostname.py b/test/units/modules/network/f5/test_bigip_hostname.py index f29790c9db..6f66e720d6 100644 --- a/test/units/modules/network/f5/test_bigip_hostname.py +++ b/test/units/modules/network/f5/test_bigip_hostname.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_hostname import Parameters from library.bigip_hostname import ModuleManager from library.bigip_hostname 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_hostname import Parameters from ansible.modules.network.f5.bigip_hostname import ModuleManager from ansible.modules.network.f5.bigip_hostname 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_irule.py b/test/units/modules/network/f5/test_bigip_irule.py index a6a26299b2..cace22da28 100644 --- a/test/units/modules/network/f5/test_bigip_irule.py +++ b/test/units/modules/network/f5/test_bigip_irule.py @@ -15,10 +15,11 @@ 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_open, Mock +from ansible.compat.tests.mock import Mock +from ansible.compat.tests.mock import patch +from ansible.compat.tests.mock import mock_open from ansible.module_utils.f5_utils import AnsibleF5Client from ansible.module_utils.six import PY3 -from units.modules.utils import set_module_args try: from library.bigip_irule import Parameters @@ -27,6 +28,7 @@ try: from library.bigip_irule import GtmManager from library.bigip_irule import LtmManager 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_irule import Parameters @@ -35,6 +37,7 @@ except ImportError: from ansible.modules.network.f5.bigip_irule import GtmManager from ansible.modules.network.f5.bigip_irule import LtmManager 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_partition.py b/test/units/modules/network/f5/test_bigip_partition.py index 23e9c8f0e8..e77e117d5c 100644 --- a/test/units/modules/network/f5/test_bigip_partition.py +++ b/test/units/modules/network/f5/test_bigip_partition.py @@ -1,21 +1,7 @@ # -*- coding: utf-8 -*- # -# Copyright 2017 F5 Networks Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public Liccense for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# Copyright (c) 2017 F5 Networks Inc. +# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import (absolute_import, division, print_function) __metaclass__ = type @@ -29,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_partition import Parameters from library.bigip_partition import ModuleManager from library.bigip_partition 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_partition import Parameters from ansible.modules.network.f5.bigip_partition import ModuleManager from ansible.modules.network.f5.bigip_partition 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_pool.py b/test/units/modules/network/f5/test_bigip_pool.py index c34959127b..6e3e625685 100644 --- a/test/units/modules/network/f5/test_bigip_pool.py +++ b/test/units/modules/network/f5/test_bigip_pool.py @@ -16,22 +16,24 @@ 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 ansible.module_utils.f5_utils import F5ModuleError -from units.modules.utils import set_module_args try: from library.bigip_pool import Parameters from library.bigip_pool import ModuleManager from library.bigip_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_pool import Parameters from ansible.modules.network.f5.bigip_pool import ModuleManager from ansible.modules.network.f5.bigip_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") diff --git a/test/units/modules/network/f5/test_bigip_qkview.py b/test/units/modules/network/f5/test_bigip_qkview.py index 55cd5e06a8..46b13ba76e 100644 --- a/test/units/modules/network/f5/test_bigip_qkview.py +++ b/test/units/modules/network/f5/test_bigip_qkview.py @@ -15,9 +15,9 @@ 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_qkview import Parameters @@ -26,6 +26,7 @@ try: from library.bigip_qkview import BulkLocationManager from library.bigip_qkview 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_qkview import Parameters @@ -34,6 +35,7 @@ except ImportError: from ansible.modules.network.f5.bigip_qkview import BulkLocationManager from ansible.modules.network.f5.bigip_qkview 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_vcmp_guest.py b/test/units/modules/network/f5/test_bigip_vcmp_guest.py index ee9fd4408d..f86828ec89 100644 --- a/test/units/modules/network/f5/test_bigip_vcmp_guest.py +++ b/test/units/modules/network/f5/test_bigip_vcmp_guest.py @@ -16,23 +16,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.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 try: from library.bigip_vcmp_guest import Parameters from library.bigip_vcmp_guest import ModuleManager from library.bigip_vcmp_guest 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_vcmp_guest import Parameters from ansible.modules.network.f5.bigip_vcmp_guest import ModuleManager from ansible.modules.network.f5.bigip_vcmp_guest 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,11 +40,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_wait.py b/test/units/modules/network/f5/test_bigip_wait.py index 7fe4d06d05..f32303f498 100644 --- a/test/units/modules/network/f5/test_bigip_wait.py +++ b/test/units/modules/network/f5/test_bigip_wait.py @@ -1,21 +1,7 @@ # -*- coding: utf-8 -*- # -# Copyright 2017 F5 Networks Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public Liccense for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# Copyright (c) 2017 F5 Networks Inc. +# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import (absolute_import, division, print_function) __metaclass__ = type @@ -30,10 +16,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, Mock +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 -from units.modules.utils import set_module_args try: from library.bigip_wait import Parameters @@ -41,6 +27,7 @@ try: from library.bigip_wait import ArgumentSpec from library.bigip_wait import AnsibleF5ClientStub 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_wait import Parameters @@ -48,6 +35,7 @@ except ImportError: from ansible.modules.network.f5.bigip_wait import ArgumentSpec from ansible.modules.network.f5.bigip_wait import AnsibleF5ClientStub 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")