mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Refactors main() function and module manager in multiple modules in line with recent changes (#53982)
Adds variable types to docs Refactors unit tests to remove deprecated parameters
This commit is contained in:
committed by
Tim Rupp
parent
1a411e9c6b
commit
348b6e7da9
@@ -98,14 +98,17 @@ class TestManager(unittest.TestCase):
|
||||
],
|
||||
partition='Common',
|
||||
state='present',
|
||||
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
|
||||
)
|
||||
mm = ModuleManager(module=module)
|
||||
|
||||
@@ -126,16 +129,19 @@ class TestManager(unittest.TestCase):
|
||||
],
|
||||
partition='Common',
|
||||
state='present',
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
current = ApiParameters(params=load_fixture('load_ltm_node_3.json'))
|
||||
|
||||
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
|
||||
)
|
||||
mm = ModuleManager(module=module)
|
||||
|
||||
@@ -156,14 +162,17 @@ class TestManager(unittest.TestCase):
|
||||
],
|
||||
partition='Common',
|
||||
state='present',
|
||||
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
|
||||
)
|
||||
mm = ModuleManager(module=module)
|
||||
|
||||
@@ -185,15 +194,18 @@ class TestManager(unittest.TestCase):
|
||||
],
|
||||
partition='Common',
|
||||
state='present',
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
current = ApiParameters(params=load_fixture('load_ltm_node_2.json'))
|
||||
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
|
||||
)
|
||||
mm = ModuleManager(module=module)
|
||||
|
||||
@@ -217,15 +229,18 @@ class TestManager(unittest.TestCase):
|
||||
],
|
||||
partition='Common',
|
||||
state='present',
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
current = ApiParameters(params=load_fixture('load_ltm_node_2.json'))
|
||||
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
|
||||
)
|
||||
mm = ModuleManager(module=module)
|
||||
|
||||
|
||||
@@ -109,9 +109,11 @@ class TestManagerEcho(unittest.TestCase):
|
||||
set_module_args(dict(
|
||||
name='foo',
|
||||
description='my description',
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
@@ -133,9 +135,11 @@ class TestManagerEcho(unittest.TestCase):
|
||||
set_module_args(dict(
|
||||
name='foo',
|
||||
description='my description',
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
current = ApiParameters(params=load_fixture('load_tm_auth_partition.json'))
|
||||
@@ -158,9 +162,11 @@ class TestManagerEcho(unittest.TestCase):
|
||||
set_module_args(dict(
|
||||
name='foo',
|
||||
description='another description',
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
current = ApiParameters(params=load_fixture('load_tm_auth_partition.json'))
|
||||
@@ -185,9 +191,11 @@ class TestManagerEcho(unittest.TestCase):
|
||||
set_module_args(dict(
|
||||
name='foo',
|
||||
route_domain=1,
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
current = ApiParameters(params=load_fixture('load_tm_auth_partition.json'))
|
||||
|
||||
@@ -128,9 +128,11 @@ class TestManager(unittest.TestCase):
|
||||
required_numeric=0,
|
||||
required_special=0,
|
||||
required_uppercase=0,
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
current = ApiParameters(params=load_fixture('load_tm_auth_password_policy_1.json'))
|
||||
|
||||
@@ -71,9 +71,6 @@ class TestParameters(unittest.TestCase):
|
||||
args = dict(
|
||||
name='foo',
|
||||
description='asdf asdf asdf',
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
)
|
||||
p = Parameters(params=args)
|
||||
assert p.name == 'foo'
|
||||
@@ -84,10 +81,7 @@ class TestParameters(unittest.TestCase):
|
||||
args = dict(
|
||||
name='foo',
|
||||
description='asdf asdf asdf',
|
||||
password='password',
|
||||
server='localhost',
|
||||
strategy='foo',
|
||||
user='admin',
|
||||
partition='Common'
|
||||
)
|
||||
p = Parameters(params=args)
|
||||
@@ -99,10 +93,7 @@ class TestParameters(unittest.TestCase):
|
||||
args = dict(
|
||||
name='foo',
|
||||
description='asdf asdf asdf',
|
||||
password='password',
|
||||
server='localhost',
|
||||
strategy='/Common/foo',
|
||||
user='admin',
|
||||
partition='Common'
|
||||
)
|
||||
p = Parameters(params=args)
|
||||
@@ -114,10 +105,7 @@ class TestParameters(unittest.TestCase):
|
||||
args = dict(
|
||||
name='foo',
|
||||
description='asdf asdf asdf',
|
||||
password='password',
|
||||
server='localhost',
|
||||
strategy='/Foo/bar',
|
||||
user='admin',
|
||||
partition='Common'
|
||||
)
|
||||
p = Parameters(params=args)
|
||||
@@ -147,9 +135,11 @@ class TestSimpleTrafficPolicyManager(unittest.TestCase):
|
||||
name="Policy-Foo",
|
||||
state='present',
|
||||
strategy='best',
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
|
||||
@@ -134,9 +134,11 @@ class TestManager(unittest.TestCase):
|
||||
path_begins_with_any=['/ABC']
|
||||
)
|
||||
],
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
@@ -173,9 +175,11 @@ class TestManager(unittest.TestCase):
|
||||
path_begins_with_any=['/ABC']
|
||||
)
|
||||
],
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
current = ApiParameters(params=load_fixture('load_ltm_policy_draft_rule_http-uri_forward.json'))
|
||||
|
||||
@@ -101,9 +101,11 @@ class TestManager(unittest.TestCase):
|
||||
description='foo',
|
||||
collect_geo=True,
|
||||
collect_ip=True,
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
|
||||
@@ -109,9 +109,11 @@ class TestManager(unittest.TestCase):
|
||||
chain='bigip_ssl_cert1'
|
||||
)
|
||||
],
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
|
||||
@@ -120,9 +120,11 @@ class TestManager(unittest.TestCase):
|
||||
process_recursion_desired=True,
|
||||
use_local_bind=True,
|
||||
enable_dns_firewall=True,
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
|
||||
@@ -158,9 +158,11 @@ class TestManager(unittest.TestCase):
|
||||
set_module_args(dict(
|
||||
name='foo',
|
||||
parent='bar',
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
|
||||
@@ -106,9 +106,11 @@ class TestManager(unittest.TestCase):
|
||||
name='foo',
|
||||
insert_xforwarded_for='yes',
|
||||
parent='bar',
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
|
||||
@@ -109,9 +109,11 @@ class TestManager(unittest.TestCase):
|
||||
name='foo',
|
||||
enforce_tls_requirements='yes',
|
||||
parent='bar',
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
|
||||
@@ -109,9 +109,11 @@ class TestManager(unittest.TestCase):
|
||||
gzip_memory_level=64,
|
||||
gzip_level=2,
|
||||
gzip_window_size=128,
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
|
||||
@@ -103,9 +103,11 @@ class TestManager(unittest.TestCase):
|
||||
name='foo',
|
||||
parent='bar',
|
||||
maximum_reuse=1000,
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
|
||||
@@ -103,9 +103,11 @@ class TestManager(unittest.TestCase):
|
||||
name='foo',
|
||||
match_across_virtuals='yes',
|
||||
parent='bar',
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
|
||||
@@ -107,9 +107,11 @@ class TestManager(unittest.TestCase):
|
||||
name='foo',
|
||||
match_across_virtuals='yes',
|
||||
parent='bar',
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
|
||||
@@ -94,14 +94,17 @@ class TestManager(unittest.TestCase):
|
||||
set_module_args(dict(
|
||||
name='foo',
|
||||
server_name='foo.bar.com',
|
||||
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,
|
||||
required_together=self.spec.required_together
|
||||
)
|
||||
mm = ModuleManager(module=module)
|
||||
|
||||
|
||||
@@ -95,9 +95,11 @@ class TestManager(unittest.TestCase):
|
||||
name='foo',
|
||||
parent='bar',
|
||||
idle_timeout=500,
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
|
||||
@@ -98,9 +98,11 @@ class TestManager(unittest.TestCase):
|
||||
parent='bar',
|
||||
idle_timeout=500,
|
||||
datagram_load_balancing=True,
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
|
||||
@@ -66,9 +66,6 @@ class TestParameters(unittest.TestCase):
|
||||
def test_module_parameters(self):
|
||||
args = dict(
|
||||
module='gtm',
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
)
|
||||
p = Parameters(params=args)
|
||||
assert p.module == 'gtm'
|
||||
@@ -88,9 +85,11 @@ class TestManager(unittest.TestCase):
|
||||
# Configure the arguments that would be sent to the Ansible module
|
||||
set_module_args(dict(
|
||||
module='gtm',
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
# Configure the parameters that would be returned by querying the
|
||||
@@ -103,7 +102,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,
|
||||
mutually_exclusive=self.spec.mutually_exclusive
|
||||
)
|
||||
mm = ModuleManager(module=module)
|
||||
|
||||
@@ -133,14 +133,17 @@ class TestManager(unittest.TestCase):
|
||||
# Configure the arguments that would be sent to the Ansible module
|
||||
set_module_args(dict(
|
||||
module=module,
|
||||
password='password',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
provider=dict(
|
||||
server='localhost',
|
||||
password='password',
|
||||
user='admin'
|
||||
)
|
||||
))
|
||||
|
||||
with patch('ansible.module_utils.basic.AnsibleModule.fail_json') as mo:
|
||||
AnsibleModule(
|
||||
argument_spec=self.spec.argument_spec,
|
||||
supports_check_mode=self.spec.supports_check_mode,
|
||||
mutually_exclusive=self.spec.mutually_exclusive
|
||||
)
|
||||
mo.assert_not_called()
|
||||
|
||||
Reference in New Issue
Block a user