Various small fixes for f5 ansible modules (#49492)

This commit is contained in:
Tim Rupp 2018-12-04 11:15:49 -08:00 committed by GitHub
commit 138690519d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 148 additions and 184 deletions

View file

@ -169,39 +169,6 @@ class TestManager(unittest.TestCase):
assert results['changed'] is True
assert results['partition_access'] == access
def test_create_user_raises(self, *args):
access = [{'name': 'Common', 'role': 'guest'}]
set_module_args(dict(
username_credential='someuser',
password_credential='testpass',
partition_access=access,
password='password',
server='localhost',
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
pm = PartitionedManager(module=module, params=module.params)
pm.create_on_device = Mock(return_value=True)
pm.exists = Mock(return_value=False)
mm = ModuleManager(module=module)
mm.is_version_less_than_13 = Mock(return_value=False)
mm.get_manager = Mock(return_value=pm)
msg = "The 'update_password' option " \
"needs to be set to 'on_create' when creating " \
"a resource with a password."
with pytest.raises(F5ModuleError) as ex:
mm.exec_module()
assert str(ex.value) == msg
def test_create_user_partition_access_raises(self, *args):
set_module_args(dict(
username_credential='someuser',
@ -589,39 +556,6 @@ class TestLegacyManager(unittest.TestCase):
assert results['changed'] is True
assert results['partition_access'] == access
def test_create_user_raises(self, *args):
access = [{'name': 'Common', 'role': 'guest'}]
set_module_args(dict(
username_credential='someuser',
password_credential='testpass',
partition_access=access,
password='password',
server='localhost',
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
upm = UnpartitionedManager(module=module, params=module.params)
upm.create_on_device = Mock(return_value=True)
upm.exists = Mock(return_value=False)
mm = ModuleManager(module=module)
mm.is_version_less_than_13 = Mock(return_value=True)
mm.get_manager = Mock(return_value=upm)
msg = "The 'update_password' option " \
"needs to be set to 'on_create' when creating " \
"a resource with a password."
with pytest.raises(F5ModuleError) as ex:
mm.exec_module()
assert str(ex.value) == msg
def test_create_user_partition_access_raises(self, *args):
set_module_args(dict(
username_credential='someuser',