Fixes unit tests in bigip_profile_http_compression (#48529)
This commit is contained in:
parent
77afc32621
commit
875d83df50
2 changed files with 16 additions and 11 deletions
|
@ -465,7 +465,7 @@ class ModuleManager(object):
|
||||||
return True
|
return True
|
||||||
raise F5ModuleError(resp.content)
|
raise F5ModuleError(resp.content)
|
||||||
|
|
||||||
def read_current_from_device(self):
|
def read_current_from_device(self): # lgtm [py/similar-function]
|
||||||
uri = "https://{0}:{1}/mgmt/tm/ltm/profile/http-compression/{2}".format(
|
uri = "https://{0}:{1}/mgmt/tm/ltm/profile/http-compression/{2}".format(
|
||||||
self.client.provider['server'],
|
self.client.provider['server'],
|
||||||
self.client.provider['server_port'],
|
self.client.provider['server_port'],
|
||||||
|
@ -527,8 +527,9 @@ def main():
|
||||||
supports_check_mode=spec.supports_check_mode,
|
supports_check_mode=spec.supports_check_mode,
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
|
||||||
client = F5RestClient(**module.params)
|
client = F5RestClient(**module.params)
|
||||||
|
|
||||||
|
try:
|
||||||
mm = ModuleManager(module=module, client=client)
|
mm = ModuleManager(module=module, client=client)
|
||||||
results = mm.exec_module()
|
results = mm.exec_module()
|
||||||
cleanup_tokens(client)
|
cleanup_tokens(client)
|
||||||
|
|
|
@ -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.bigip_profile_http_compression import ModuleParameters
|
from library.modules.bigip_profile_http_compression import ModuleParameters
|
||||||
from library.modules.bigip_profile_http_compression import ModuleManager
|
from library.modules.bigip_profile_http_compression import ModuleManager
|
||||||
from library.modules.bigip_profile_http_compression import ArgumentSpec
|
from library.modules.bigip_profile_http_compression 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.bigip_profile_http_compression import ApiParameters
|
from ansible.modules.network.f5.bigip_profile_http_compression import ApiParameters
|
||||||
from ansible.modules.network.f5.bigip_profile_http_compression import ModuleParameters
|
from ansible.modules.network.f5.bigip_profile_http_compression import ModuleParameters
|
||||||
from ansible.modules.network.f5.bigip_profile_http_compression import ModuleManager
|
from ansible.modules.network.f5.bigip_profile_http_compression import ModuleManager
|
||||||
from ansible.modules.network.f5.bigip_profile_http_compression import ArgumentSpec
|
from ansible.modules.network.f5.bigip_profile_http_compression 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")
|
||||||
|
|
Loading…
Reference in a new issue