Refactors main() function and module manager in multiple modules in line with recent changes (#53954)

Adds variable types to docs
Refactors unit tests to remove deprecated parameters
Adds missing Return values to documentation
Removes deprecated modules unit tests
This commit is contained in:
Wojciech Wypior
2019-03-19 15:59:14 +01:00
committed by John R Barker
parent dcf40d43ea
commit e13cb29e23
34 changed files with 478 additions and 1118 deletions

View File

@@ -1,577 +0,0 @@
# -*- coding: utf-8 -*-
#
# 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
import os
import json
import pytest
import sys
if sys.version_info < (2, 7):
pytestmark = pytest.mark.skip("F5 Ansible modules require Python >= 2.7")
from ansible.module_utils.basic import AnsibleModule
try:
from library.modules._bigip_asm_policy import V1Parameters
from library.modules._bigip_asm_policy import V2Parameters
from library.modules._bigip_asm_policy import ModuleManager
from library.modules._bigip_asm_policy import V1Manager
from library.modules._bigip_asm_policy import V2Manager
from library.modules._bigip_asm_policy import ArgumentSpec
from library.module_utils.network.f5.common import F5ModuleError
# 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:
from ansible.modules.network.f5._bigip_asm_policy import V1Parameters
from ansible.modules.network.f5._bigip_asm_policy import V2Parameters
from ansible.modules.network.f5._bigip_asm_policy import ModuleManager
from ansible.modules.network.f5._bigip_asm_policy import V1Manager
from ansible.modules.network.f5._bigip_asm_policy import V2Manager
from ansible.modules.network.f5._bigip_asm_policy import ArgumentSpec
from ansible.module_utils.network.f5.common import F5ModuleError
# 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
fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures')
fixture_data = {}
def load_fixture(name):
path = os.path.join(fixture_path, name)
with open(path) as f:
data = f.read()
try:
data = json.loads(data)
except Exception:
pass
return data
class TestParameters(unittest.TestCase):
def test_module_parameters(self):
args = dict(
name='fake_policy',
state='present',
file='/var/fake/fake.xml'
)
p = V1Parameters(params=args)
assert p.name == 'fake_policy'
assert p.state == 'present'
assert p.file == '/var/fake/fake.xml'
def test_module_parameters_template(self):
args = dict(
name='fake_policy',
state='present',
template='LotusDomino 6.5 (http)'
)
p = V1Parameters(params=args)
assert p.name == 'fake_policy'
assert p.state == 'present'
assert p.template == 'POLICY_TEMPLATE_LOTUSDOMINO_6_5_HTTP'
class TestManager(unittest.TestCase):
def setUp(self):
self.spec = ArgumentSpec()
self.policy = os.path.join(fixture_path, 'fake_policy.xml')
self.patcher1 = patch('time.sleep')
self.patcher1.start()
try:
self.p1 = patch('library.modules._bigip_asm_policy.module_provisioned')
self.m1 = self.p1.start()
self.m1.return_value = True
except Exception:
self.p1 = patch('ansible.modules.network.f5._bigip_asm_policy.module_provisioned')
self.m1 = self.p1.start()
self.m1.return_value = True
def tearDown(self):
self.patcher1.stop()
self.p1.stop()
def test_activate_import_from_file(self, *args):
set_module_args(dict(
name='fake_policy',
file=self.policy,
state='present',
active='yes',
server='localhost',
password='password',
user='admin',
))
current = V1Parameters(params=load_fixture('load_asm_policy_inactive.json'))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
)
v1 = V1Manager(module=module)
v1.exists = Mock(return_value=False)
v1.import_to_device = Mock(return_value=True)
v1.wait_for_task = Mock(side_effect=[True, True])
v1.read_current_from_device = Mock(return_value=current)
v1.apply_on_device = Mock(return_value=True)
v1.remove_temp_policy_from_device = Mock(return_value=True)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(module=module)
mm.version_is_less_than_13 = Mock(return_value=False)
mm.get_manager = Mock(return_value=v1)
results = mm.exec_module()
assert results['changed'] is True
assert results['name'] == 'fake_policy'
assert results['file'] == self.policy
assert results['active'] is True
def test_activate_import_from_template(self, *args):
set_module_args(dict(
name='fake_policy',
template='OWA Exchange 2007 (https)',
state='present',
active='yes',
server='localhost',
password='password',
user='admin',
))
current = V1Parameters(params=load_fixture('load_asm_policy_inactive.json'))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
v1 = V1Manager(module=module)
v1.exists = Mock(return_value=False)
v1.import_to_device = Mock(return_value=True)
v1.wait_for_task = Mock(side_effect=[True, True])
v1.read_current_from_device = Mock(return_value=current)
v1.apply_on_device = Mock(return_value=True)
v1.create_from_template_on_device = Mock(return_value=True)
v1._file_is_missing = Mock(return_value=False)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(module=module)
mm.version_is_less_than_13 = Mock(return_value=False)
mm.get_manager = Mock(return_value=v1)
results = mm.exec_module()
assert results['changed'] is True
assert results['name'] == 'fake_policy'
assert results['template'] == 'OWA Exchange 2007 (https)'
assert results['active'] is True
def test_activate_create_by_name(self, *args):
set_module_args(dict(
name='fake_policy',
state='present',
active='yes',
server='localhost',
password='password',
user='admin',
))
current = V1Parameters(params=load_fixture('load_asm_policy_inactive.json'))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
v1 = V1Manager(module=module)
v1.exists = Mock(return_value=False)
v1.import_to_device = Mock(return_value=True)
v1.wait_for_task = Mock(side_effect=[True, True])
v1.create_on_device = Mock(return_value=True)
v1.create_blank = Mock(return_value=True)
v1.read_current_from_device = Mock(return_value=current)
v1.apply_on_device = Mock(return_value=True)
v1._file_is_missing = Mock(return_value=False)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(module=module)
mm.version_is_less_than_13 = Mock(return_value=False)
mm.get_manager = Mock(return_value=v1)
results = mm.exec_module()
assert results['changed'] is True
assert results['name'] == 'fake_policy'
assert results['active'] is True
def test_activate_policy_exists_inactive(self, *args):
set_module_args(dict(
name='fake_policy',
state='present',
active='yes',
server='localhost',
password='password',
user='admin',
))
current = V1Parameters(params=load_fixture('load_asm_policy_inactive.json'))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
v1 = V1Manager(module=module)
v1.exists = Mock(return_value=True)
v1.update_on_device = Mock(return_value=True)
v1.wait_for_task = Mock(side_effect=[True, True])
v1.read_current_from_device = Mock(return_value=current)
v1.apply_on_device = Mock(return_value=True)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(module=module)
mm.version_is_less_than_13 = Mock(return_value=False)
mm.get_manager = Mock(return_value=v1)
results = mm.exec_module()
assert results['changed'] is True
assert results['active'] is True
def test_activate_policy_exists_active(self, *args):
set_module_args(dict(
name='fake_policy',
state='present',
active='yes',
server='localhost',
password='password',
user='admin',
))
current = V1Parameters(params=load_fixture('load_asm_policy_active.json'))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
# Override methods to force specific logic in the module to happen
v1 = V1Manager(module=module)
v1.exists = Mock(return_value=True)
v1.read_current_from_device = Mock(return_value=current)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(module=module)
mm.version_is_less_than_13 = Mock(return_value=False)
mm.get_manager = Mock(return_value=v1)
results = mm.exec_module()
assert results['changed'] is False
def test_deactivate_policy_exists_active(self, *args):
set_module_args(dict(
name='fake_policy',
state='present',
server='localhost',
password='password',
user='admin',
active='no'
))
current = V1Parameters(params=load_fixture('load_asm_policy_active.json'))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
# Override methods to force specific logic in the module to happen
v1 = V1Manager(module=module)
v1.exists = Mock(return_value=True)
v1.read_current_from_device = Mock(return_value=current)
v1.update_on_device = Mock(return_value=True)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(module=module)
mm.version_is_less_than_13 = Mock(return_value=False)
mm.get_manager = Mock(return_value=v1)
results = mm.exec_module()
assert results['changed'] is True
assert results['active'] is False
def test_deactivate_policy_exists_inactive(self, *args):
set_module_args(dict(
name='fake_policy',
state='present',
server='localhost',
password='password',
user='admin',
active='no'
))
current = V1Parameters(params=load_fixture('load_asm_policy_inactive.json'))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
# Override methods to force specific logic in the module to happen
v1 = V1Manager(module=module)
v1.exists = Mock(return_value=True)
v1.read_current_from_device = Mock(return_value=current)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(module=module)
mm.version_is_less_than_13 = Mock(return_value=False)
mm.get_manager = Mock(return_value=v1)
results = mm.exec_module()
assert results['changed'] is False
def test_import_from_file(self, *args):
set_module_args(dict(
name='fake_policy',
file=self.policy,
state='present',
server='localhost',
password='password',
user='admin',
))
current = V1Parameters(params=load_fixture('load_asm_policy_inactive.json'))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
# Override methods to force specific logic in the module to happen
v1 = V1Manager(module=module)
v1.exists = Mock(return_value=False)
v1.import_to_device = Mock(return_value=True)
v1.wait_for_task = Mock(side_effect=[True, True])
v1.read_current_from_device = Mock(return_value=current)
v1.remove_temp_policy_from_device = Mock(return_value=True)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(module=module)
mm.version_is_less_than_13 = Mock(return_value=False)
mm.get_manager = Mock(return_value=v1)
results = mm.exec_module()
assert results['changed'] is True
assert results['name'] == 'fake_policy'
assert results['file'] == self.policy
assert results['active'] is False
def test_import_from_template(self, *args):
set_module_args(dict(
name='fake_policy',
template='LotusDomino 6.5 (http)',
state='present',
server='localhost',
password='password',
user='admin',
))
current = V1Parameters(params=load_fixture('load_asm_policy_inactive.json'))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
# Override methods to force specific logic in the module to happen
v1 = V1Manager(module=module)
v1.exists = Mock(return_value=False)
v1.create_from_template_on_device = Mock(return_value=True)
v1.wait_for_task = Mock(side_effect=[True, True])
v1.read_current_from_device = Mock(return_value=current)
v1._file_is_missing = Mock(return_value=False)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(module=module)
mm.version_is_less_than_13 = Mock(return_value=False)
mm.get_manager = Mock(return_value=v1)
results = mm.exec_module()
assert results['changed'] is True
assert results['name'] == 'fake_policy'
assert results['template'] == 'LotusDomino 6.5 (http)'
assert results['active'] is False
def test_create_by_name(self, *args):
set_module_args(dict(
name='fake_policy',
state='present',
server='localhost',
password='password',
user='admin',
))
current = V1Parameters(params=load_fixture('load_asm_policy_inactive.json'))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
v1 = V1Manager(module=module)
v1.exists = Mock(return_value=False)
v1.import_to_device = Mock(return_value=True)
v1.wait_for_task = Mock(side_effect=[True, True])
v1.create_on_device = Mock(return_value=True)
v1.create_blank = Mock(return_value=True)
v1.read_current_from_device = Mock(return_value=current)
v1.apply_on_device = Mock(return_value=True)
v1._file_is_missing = Mock(return_value=False)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(module=module)
mm.version_is_less_than_13 = Mock(return_value=False)
mm.get_manager = Mock(return_value=v1)
results = mm.exec_module()
assert results['changed'] is True
assert results['name'] == 'fake_policy'
assert results['active'] is False
def test_delete_policy(self, *args):
set_module_args(dict(
name='fake_policy',
state='absent',
server='localhost',
password='password',
user='admin',
))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
# Override methods to force specific logic in the module to happen
v1 = V1Manager(module=module)
v1.exists = Mock(side_effect=[True, False])
v1.remove_from_device = Mock(return_value=True)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(module=module)
mm.version_is_less_than_13 = Mock(return_value=False)
mm.get_manager = Mock(return_value=v1)
results = mm.exec_module()
assert results['changed'] is True
def test_activate_policy_raises(self, *args):
set_module_args(dict(
name='fake_policy',
state='present',
active='yes',
server='localhost',
password='password',
user='admin',
))
current = V1Parameters(params=load_fixture('load_asm_policy_inactive.json'))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
msg = 'Apply policy task failed.'
# Override methods to force specific logic in the module to happen
v1 = V1Manager(module=module)
v1.exists = Mock(return_value=True)
v1.wait_for_task = Mock(return_value=False)
v1.update_on_device = Mock(return_value=True)
v1.read_current_from_device = Mock(return_value=current)
v1.apply_on_device = Mock(return_value=True)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(module=module)
mm.version_is_less_than_13 = Mock(return_value=False)
mm.get_manager = Mock(return_value=v1)
with pytest.raises(F5ModuleError) as err:
mm.exec_module()
assert str(err.value) == msg
def test_create_policy_raises(self, *args):
set_module_args(dict(
name='fake_policy',
state='present',
server='localhost',
password='password',
user='admin',
))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
msg = 'Failed to create ASM policy: fake_policy'
# Override methods to force specific logic in the module to happen
v1 = V1Manager(module=module)
v1.exists = Mock(return_value=False)
v1.create_on_device = Mock(return_value=False)
v1._file_is_missing = Mock(return_value=False)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(module=module)
mm.version_is_less_than_13 = Mock(return_value=False)
mm.get_manager = Mock(return_value=v1)
with pytest.raises(F5ModuleError) as err:
mm.exec_module()
assert str(err.value) == msg
def test_delete_policy_raises(self, *args):
set_module_args(dict(
name='fake_policy',
state='absent',
server='localhost',
password='password',
user='admin',
))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
msg = 'Failed to delete ASM policy: fake_policy'
# Override methods to force specific logic in the module to happen
v1 = V1Manager(module=module)
v1.exists = Mock(side_effect=[True, True])
v1.remove_from_device = Mock(return_value=True)
# Override methods to force specific logic in the module to happen
mm = ModuleManager(module=module)
mm.version_is_less_than_13 = Mock(return_value=False)
mm.get_manager = Mock(return_value=v1)
with pytest.raises(F5ModuleError) as err:
mm.exec_module()
assert str(err.value) == msg

View File

@@ -98,9 +98,11 @@ class TestManager(unittest.TestCase):
description='another description',
scope='shared',
state="present",
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
)
)

View File

@@ -94,9 +94,11 @@ class TestManager(unittest.TestCase):
set_module_args(dict(
name='foo',
content='asdasds',
server='localhost',
password='password',
user='admin'
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
module = AnsibleModule(

View File

@@ -66,9 +66,6 @@ class TestParameters(unittest.TestCase):
commands=[
"tmsh show sys version"
],
server='localhost',
user='admin',
password='password'
)
p = Parameters(params=args)
assert len(p.commands) == 1
@@ -89,9 +86,11 @@ class TestManager(unittest.TestCase):
commands=[
"tmsh show sys version"
],
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
module = AnsibleModule(
@@ -117,9 +116,11 @@ class TestManager(unittest.TestCase):
commands=[
"tmsh create ltm virtual foo"
],
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
module = AnsibleModule(
@@ -145,10 +146,12 @@ class TestManager(unittest.TestCase):
commands=[
"show sys version"
],
server='localhost',
user='admin',
password='password',
transport='cli'
provider=dict(
server='localhost',
password='password',
user='admin',
transport='cli'
)
))
module = AnsibleModule(
@@ -186,9 +189,11 @@ class TestManager(unittest.TestCase):
enabled search-base-dn cn=users,dc=domain,dc=com servers add {
ldap.server.com } }
""",
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,

View File

@@ -69,9 +69,6 @@ class TestParameters(unittest.TestCase):
reset='yes',
merge_content='asdasd',
verify='no',
server='localhost',
user='admin',
password='password'
)
p = Parameters(params=args)
assert p.save == 'yes'
@@ -90,9 +87,11 @@ class TestManager(unittest.TestCase):
reset='yes',
merge_content='asdasd',
verify='no',
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
module = AnsibleModule(

View File

@@ -104,14 +104,18 @@ class TestManager(unittest.TestCase):
set_module_args(dict(
sync_device_to_group='yes',
device_group="foo",
password='password',
server='localhost',
user='admin'
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
supports_check_mode=self.spec.supports_check_mode,
mutually_exclusive=self.spec.mutually_exclusive,
required_one_of=self.spec.required_one_of
)
mm = ModuleManager(module=module)

View File

@@ -1,134 +0,0 @@
# -*- 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 License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
import json
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 patch, Mock
from ansible.module_utils.f5_utils import AnsibleF5Client
from units.modules.utils import set_module_args
try:
from library.bigip_configsync_actions import Parameters
from library.bigip_configsync_actions import ModuleManager
from library.bigip_configsync_actions import ArgumentSpec
except ImportError:
try:
from ansible.modules.network.f5.bigip_configsync_actions import Parameters
from ansible.modules.network.f5.bigip_configsync_actions import ModuleManager
from ansible.modules.network.f5.bigip_configsync_actions import ArgumentSpec
except ImportError:
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures')
fixture_data = {}
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
class TestParameters(unittest.TestCase):
def test_module_parameters(self):
args = dict(
sync_device_to_group=True,
sync_group_to_device=True,
overwrite_config=True,
device_group="foo"
)
p = Parameters(args)
assert p.sync_device_to_group is True
assert p.sync_group_to_device is True
assert p.overwrite_config is True
assert p.device_group == 'foo'
def test_module_parameters_yes_no(self):
args = dict(
sync_device_to_group='yes',
sync_group_to_device='no',
overwrite_config='yes',
device_group="foo"
)
p = Parameters(args)
assert p.sync_device_to_group is True
assert p.sync_group_to_device is False
assert p.overwrite_config is True
assert p.device_group == 'foo'
@patch('ansible.module_utils.f5_utils.AnsibleF5Client._get_mgmt_root',
return_value=True)
class TestManager(unittest.TestCase):
def setUp(self):
self.spec = ArgumentSpec()
def test_update_agent_status_traps(self, *args):
set_module_args(dict(
sync_device_to_group='yes',
device_group="foo",
password='passsword',
server='localhost',
user='admin'
))
client = AnsibleF5Client(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode,
f5_product_name=self.spec.f5_product_name
)
mm = ModuleManager(client)
# Override methods to force specific logic in the module to happen
mm._device_group_exists = Mock(return_value=True)
mm._sync_to_group_required = Mock(return_value=False)
mm.execute_on_device = Mock(return_value=True)
mm.read_current_from_device = Mock(return_value=None)
mm._get_status_from_resource = Mock()
mm._get_status_from_resource.side_effect = [
'Changes Pending', 'Awaiting Initial Sync', 'In Sync'
]
results = mm.exec_module()
assert results['changed'] is True

View File

@@ -85,9 +85,6 @@ class TestParameters(unittest.TestCase):
mirror_secondary_address='5.6.7.8',
config_sync_ip='4.3.2.1',
state='present',
server='localhost',
user='admin',
password='password'
)
p = ModuleParameters(params=args)
assert p.multicast_port == 1010
@@ -141,9 +138,11 @@ class TestManager(unittest.TestCase):
address="10.1.30.1"
)
],
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
# Configure the parameters that would be returned by querying the
@@ -152,7 +151,8 @@ class TestManager(unittest.TestCase):
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
supports_check_mode=self.spec.supports_check_mode,
required_together=self.spec.required_together
)
mm = ModuleManager(module=module)
@@ -170,9 +170,11 @@ class TestManager(unittest.TestCase):
def test_set_primary_mirror_address_none(self, *args):
set_module_args(dict(
mirror_primary_address="none",
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
# Configure the parameters that would be returned by querying the
@@ -181,7 +183,8 @@ class TestManager(unittest.TestCase):
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
supports_check_mode=self.spec.supports_check_mode,
required_together=self.spec.required_together
)
mm = ModuleManager(module=module)
@@ -198,9 +201,11 @@ class TestManager(unittest.TestCase):
def test_set_secondary_mirror_address_none(self, *args):
set_module_args(dict(
mirror_secondary_address="none",
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
# Configure the parameters that would be returned by querying the
@@ -209,7 +214,8 @@ class TestManager(unittest.TestCase):
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
supports_check_mode=self.spec.supports_check_mode,
required_together=self.spec.required_together
)
mm = ModuleManager(module=module)
@@ -226,9 +232,13 @@ class TestManager(unittest.TestCase):
def test_set_multicast_address_none(self, *args):
set_module_args(dict(
multicast_address="none",
server='localhost',
user='admin',
password='password'
multicast_port=62960,
multicast_interface="eth0",
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
# Configure the parameters that would be returned by querying the
@@ -237,7 +247,8 @@ class TestManager(unittest.TestCase):
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
supports_check_mode=self.spec.supports_check_mode,
required_together=self.spec.required_together
)
mm = ModuleManager(module=module)
@@ -254,9 +265,13 @@ class TestManager(unittest.TestCase):
def test_set_multicast_port_negative(self, *args):
set_module_args(dict(
multicast_port=-1,
server='localhost',
user='admin',
password='password'
multicast_address="224.0.0.245",
multicast_interface="eth0",
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
# Configure the parameters that would be returned by querying the
@@ -265,7 +280,8 @@ class TestManager(unittest.TestCase):
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
supports_check_mode=self.spec.supports_check_mode,
required_together=self.spec.required_together
)
mm = ModuleManager(module=module)
@@ -281,9 +297,13 @@ class TestManager(unittest.TestCase):
def test_set_multicast_address(self, *args):
set_module_args(dict(
multicast_address="10.1.1.1",
server='localhost',
user='admin',
password='password'
multicast_port=62960,
multicast_interface="eth0",
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
# Configure the parameters that would be returned by querying the
@@ -292,7 +312,8 @@ class TestManager(unittest.TestCase):
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
supports_check_mode=self.spec.supports_check_mode,
required_together=self.spec.required_together
)
mm = ModuleManager(module=module)
@@ -309,9 +330,11 @@ class TestManager(unittest.TestCase):
def test_unset_unicast_failover(self, *args):
set_module_args(dict(
unicast_failover="none",
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
# Configure the parameters that would be returned by querying the
@@ -320,7 +343,8 @@ class TestManager(unittest.TestCase):
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
supports_check_mode=self.spec.supports_check_mode,
required_together=self.spec.required_together
)
mm = ModuleManager(module=module)
@@ -337,9 +361,11 @@ class TestManager(unittest.TestCase):
def test_unset_config_sync_ip(self, *args):
set_module_args(dict(
config_sync_ip="none",
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
# Configure the parameters that would be returned by querying the
@@ -348,7 +374,8 @@ class TestManager(unittest.TestCase):
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
supports_check_mode=self.spec.supports_check_mode,
required_together=self.spec.required_together
)
mm = ModuleManager(module=module)

View File

@@ -69,9 +69,6 @@ class TestParameters(unittest.TestCase):
ip_version=4,
name_servers=['10.10.10.10', '11.11.11.11'],
search=['14.14.14.14', '15.15.15.15'],
server='localhost',
user='admin',
password='password'
)
p = Parameters(params=args)
assert p.cache == 'disable'
@@ -100,9 +97,11 @@ class TestManager(unittest.TestCase):
ip_version=4,
name_servers=['10.10.10.10', '11.11.11.11'],
search=['14.14.14.14', '15.15.15.15'],
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
# Configure the parameters that would be returned by querying the
@@ -115,7 +114,8 @@ class TestManager(unittest.TestCase):
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
supports_check_mode=self.spec.supports_check_mode,
required_one_of=self.spec.required_one_of
)
mm = ModuleManager(module=module)

View File

@@ -110,9 +110,11 @@ class TestModuleManager(unittest.TestCase):
dict(
name="foo-group",
state="present",
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
)
)
@@ -135,9 +137,11 @@ class TestModuleManager(unittest.TestCase):
full_sync=True,
name="foo-group",
state="present",
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
)
)
@@ -161,9 +165,11 @@ class TestModuleManager(unittest.TestCase):
dict(
name="foo-group",
state="absent",
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
)
)

View File

@@ -84,9 +84,11 @@ class TestManager(unittest.TestCase):
name="bigip1",
device_group="dg1",
state="present",
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
)
)

View File

@@ -105,9 +105,11 @@ class TestModuleManager(unittest.TestCase):
max_clients='20',
redirect_http_to_https='yes',
ssl_port=8443,
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
)
)
@@ -130,9 +132,11 @@ class TestModuleManager(unittest.TestCase):
set_module_args(
dict(
ssl_cipher_suite='ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384',
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
)
)
@@ -159,9 +163,11 @@ class TestModuleManager(unittest.TestCase):
'ECDHE-RSA-AES128-GCM-SHA256',
'ECDHE-RSA-AES256-GCM-SHA384'
],
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
)
)
@@ -185,9 +191,11 @@ class TestModuleManager(unittest.TestCase):
set_module_args(
dict(
ssl_cipher_suite='default',
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
)
)
@@ -211,9 +219,11 @@ class TestModuleManager(unittest.TestCase):
set_module_args(
dict(
ssl_protocols='all -SSLv2',
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
)
)
@@ -240,9 +250,11 @@ class TestModuleManager(unittest.TestCase):
'all',
'-SSLv2'
],
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
)
)
@@ -266,9 +278,11 @@ class TestModuleManager(unittest.TestCase):
set_module_args(
dict(
ssl_protocols='default',
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
)
)

View File

@@ -94,15 +94,18 @@ class TestModuleManager(unittest.TestCase):
license_key='xxxx-yyyy-zzzz',
license_server='foo-license.f5.com',
accept_eula=True,
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
)
)
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
supports_check_mode=self.spec.supports_check_mode,
required_if=self.spec.required_if
)
mm = ModuleManager(module=module)

View File

@@ -96,9 +96,11 @@ class TestModuleManager(unittest.TestCase):
set_module_args(
dict(
ntp_servers=ntp,
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
)
)
@@ -108,7 +110,8 @@ class TestModuleManager(unittest.TestCase):
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
supports_check_mode=self.spec.supports_check_mode,
required_one_of=self.spec.required_one_of
)
mm = ModuleManager(module=module)
@@ -124,9 +127,11 @@ class TestModuleManager(unittest.TestCase):
set_module_args(
dict(
timezone='Arctic/Longyearbyen',
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
)
)
@@ -136,7 +141,8 @@ class TestModuleManager(unittest.TestCase):
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
supports_check_mode=self.spec.supports_check_mode,
required_one_of=self.spec.required_one_of
)
mm = ModuleManager(module=module)
@@ -154,9 +160,11 @@ class TestModuleManager(unittest.TestCase):
dict(
ntp_servers=ntp,
timezone='Arctic/Longyearbyen',
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
)
)
@@ -166,7 +174,8 @@ class TestModuleManager(unittest.TestCase):
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
supports_check_mode=self.spec.supports_check_mode,
required_one_of=self.spec.required_one_of
)
mm = ModuleManager(module=module)
@@ -185,10 +194,12 @@ class TestModuleManager(unittest.TestCase):
dict(
ntp_servers=ntp,
timezone='America/Los_Angeles',
server='localhost',
user='admin',
password='password',
state='absent'
state='absent',
provider=dict(
server='localhost',
password='password',
user='admin'
)
)
)
@@ -198,7 +209,8 @@ class TestModuleManager(unittest.TestCase):
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
supports_check_mode=self.spec.supports_check_mode,
required_one_of=self.spec.required_one_of
)
mm = ModuleManager(module=module)
@@ -215,10 +227,12 @@ class TestModuleManager(unittest.TestCase):
set_module_args(
dict(
timezone='',
server='localhost',
user='admin',
password='password',
state='absent'
state='absent',
provider=dict(
server='localhost',
password='password',
user='admin'
)
)
)
@@ -228,7 +242,8 @@ class TestModuleManager(unittest.TestCase):
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
supports_check_mode=self.spec.supports_check_mode,
required_one_of=self.spec.required_one_of
)
mm = ModuleManager(module=module)

View File

@@ -74,9 +74,6 @@ class TestParameters(unittest.TestCase):
log_level='debug',
login='enabled',
port=1010,
server='localhost',
user='admin',
password='password'
)
p = ModuleParameters(params=args)
assert p.allow == ['all']
@@ -102,9 +99,11 @@ class TestManager(unittest.TestCase):
log_level='debug',
login='enabled',
port=1010,
server='localhost',
user='admin',
password='password'
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
# Configure the parameters that would be returned by querying the

View File

@@ -89,9 +89,11 @@ class TestUntypedManager(unittest.TestCase):
set_module_args(dict(
kern_from='emerg',
kern_to='debug',
password='password',
server='localhost',
user='admin'
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
module = AnsibleModule(

View File

@@ -137,9 +137,11 @@ class TestManager(unittest.TestCase):
peer_hostname='foo.bar.baz',
peer_user='admin',
peer_password='secret',
server='localhost',
password='password',
user='admin'
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
module = AnsibleModule(
@@ -162,9 +164,11 @@ class TestManager(unittest.TestCase):
peer_hostname='foo.bar.baz',
peer_user='admin',
peer_password='secret',
server='localhost',
password='password',
user='admin'
provider=dict(
server='localhost',
password='password',
user='admin'
)
))
module = AnsibleModule(