1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Adds fixes to the bigiq unit tests (#47763)

The tests were not working on ansible 2.8. This fixes that.
This commit is contained in:
Tim Rupp 2018-10-29 10:41:35 -07:00 committed by GitHub
parent 6e28b7d572
commit cbc8571809
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 18 deletions

View file

@ -8,16 +8,12 @@ __metaclass__ = type
import os import os
import json import json
import pytest
import sys import sys
from nose.plugins.skip import SkipTest from nose.plugins.skip import SkipTest
if sys.version_info < (2, 7): if sys.version_info < (2, 7):
raise SkipTest("F5 Ansible modules require Python >= 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 from ansible.module_utils.basic import AnsibleModule
try: try:
@ -25,17 +21,25 @@ try:
from library.modules.bigiq_regkey_license_assignment import ModuleParameters from library.modules.bigiq_regkey_license_assignment import ModuleParameters
from library.modules.bigiq_regkey_license_assignment import ModuleManager from library.modules.bigiq_regkey_license_assignment import ModuleManager
from library.modules.bigiq_regkey_license_assignment import ArgumentSpec from library.modules.bigiq_regkey_license_assignment import ArgumentSpec
from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError # In Ansible 2.8, Ansible changed import paths.
from test.unit.modules.utils import set_module_args 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: except ImportError:
try: try:
from ansible.modules.network.f5.bigiq_regkey_license_assignment import ApiParameters from ansible.modules.network.f5.bigiq_regkey_license_assignment import ApiParameters
from ansible.modules.network.f5.bigiq_regkey_license_assignment import ModuleParameters from ansible.modules.network.f5.bigiq_regkey_license_assignment import ModuleParameters
from ansible.modules.network.f5.bigiq_regkey_license_assignment import ModuleManager from ansible.modules.network.f5.bigiq_regkey_license_assignment import ModuleManager
from ansible.modules.network.f5.bigiq_regkey_license_assignment import ArgumentSpec from ansible.modules.network.f5.bigiq_regkey_license_assignment 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 from units.modules.utils import set_module_args
except ImportError: except ImportError:
raise SkipTest("F5 Ansible modules require the f5-sdk Python library") raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
@ -102,6 +106,11 @@ class TestManager(unittest.TestCase):
def setUp(self): def setUp(self):
self.spec = ArgumentSpec() self.spec = ArgumentSpec()
self.patcher1 = patch('time.sleep')
self.patcher1.start()
def tearDown(self):
self.patcher1.stop()
def test_create(self, *args): def test_create(self, *args):
set_module_args(dict( set_module_args(dict(

View file

@ -8,32 +8,36 @@ __metaclass__ = type
import os import os
import json import json
import pytest
import sys import sys
from nose.plugins.skip import SkipTest from nose.plugins.skip import SkipTest
if sys.version_info < (2, 7): if sys.version_info < (2, 7):
raise SkipTest("F5 Ansible modules require Python >= 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 from ansible.module_utils.basic import AnsibleModule
try: try:
from library.modules.bigiq_utility_license import ModuleParameters from library.modules.bigiq_utility_license import ModuleParameters
from library.modules.bigiq_utility_license import ModuleManager from library.modules.bigiq_utility_license import ModuleManager
from library.modules.bigiq_utility_license import ArgumentSpec from library.modules.bigiq_utility_license import ArgumentSpec
from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError # In Ansible 2.8, Ansible changed import paths.
from test.unit.modules.utils import set_module_args 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: except ImportError:
try: try:
from ansible.modules.network.f5.bigiq_utility_license import ModuleParameters from ansible.modules.network.f5.bigiq_utility_license import ModuleParameters
from ansible.modules.network.f5.bigiq_utility_license import ModuleManager from ansible.modules.network.f5.bigiq_utility_license import ModuleManager
from ansible.modules.network.f5.bigiq_utility_license import ArgumentSpec from ansible.modules.network.f5.bigiq_utility_license 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 from units.modules.utils import set_module_args
except ImportError: except ImportError:
raise SkipTest("F5 Ansible modules require the f5-sdk Python library") raise SkipTest("F5 Ansible modules require the f5-sdk Python library")