def test_create_pool_with_metadata(self, *args): set_module_args( dict(pool='fake_pool', metadata=dict(ansible='2.4'), provider=dict(server='localhost', password='******', user='******'))) module = AnsibleModule( argument_spec=self.spec.argument_spec, 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) mm.create_on_device = Mock(return_value=True) mm.exists = Mock(return_value=False) results = mm.exec_module() assert results['changed'] is True assert results['name'] == 'fake_pool' assert 'metadata' in results assert 'ansible' in results['metadata'] assert results['metadata']['ansible'] == '2.4'
def test_create_pool_monitor_m_of_n_custom_partition(self, *args): set_module_args( dict(pool='fake_pool', partition='Testing', monitor_type='m_of_n', quorum=1, monitors=['tcp', 'http'], provider=dict(server='localhost', password='******', user='******'))) module = AnsibleModule( argument_spec=self.spec.argument_spec, 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) mm.create_on_device = Mock(return_value=True) mm.exists = Mock(return_value=False) results = mm.exec_module() assert results['changed'] is True assert results['name'] == 'fake_pool' assert results['monitors'] == ['/Testing/http', '/Testing/tcp'] assert results['monitor_type'] == 'm_of_n'
def test_create_pool_quorum_missing(self, *args): set_module_args( dict(pool='fake_pool', lb_method='round-robin', partition='Common', monitor_type='m_of_n', monitors=['/Common/tcp', '/Common/http'], provider=dict(server='localhost', password='******', user='******'))) module = AnsibleModule( argument_spec=self.spec.argument_spec, 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) mm.create_on_device = Mock(return_value=True) mm.exists = Mock(return_value=False) msg = "Quorum value must be specified with monitor_type 'm_of_n'." with pytest.raises(F5ModuleError) as err: mm.exec_module() assert str(err.value) == msg
def test_create_pool_monitors_missing(self, *args): set_module_args( dict(pool='fake_pool', lb_method='round-robin', partition='Common', monitor_type='and_list', provider=dict(server='localhost', password='******', user='******'))) module = AnsibleModule( argument_spec=self.spec.argument_spec, 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) mm.create_on_device = Mock(return_value=True) mm.exists = Mock(return_value=False) msg = "The 'monitors' parameter cannot be empty when " \ "'monitor_type' parameter is specified" with pytest.raises(F5ModuleError) as err: mm.exec_module() assert str(err.value) == msg
def test_create_pool_monitor_type_missing(self, *args): set_module_args( dict(pool='fake_pool', lb_method='round-robin', partition='Common', monitors=['/Common/tcp', '/Common/http'], provider=dict(server='localhost', password='******', user='******'))) module = AnsibleModule( argument_spec=self.spec.argument_spec, 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) mm.create_on_device = Mock(return_value=True) mm.exists = Mock(return_value=False) results = mm.exec_module() assert results['changed'] is True assert results['name'] == 'fake_pool' assert results['monitors'] == ['/Common/http', '/Common/tcp'] assert results['monitor_type'] == 'and_list'
def test_create_pool(self, *args): set_module_args( dict(pool='fake_pool', description='fakepool', service_down_action='drop', lb_method='round-robin', partition='Common', slow_ramp_time=10, reselect_tries=1, provider=dict(server='localhost', password='******', user='******'))) module = AnsibleModule( argument_spec=self.spec.argument_spec, 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) mm.create_on_device = Mock(return_value=True) mm.exists = Mock(return_value=False) results = mm.exec_module() assert results['changed'] is True assert results['name'] == 'fake_pool' assert results['description'] == 'fakepool' assert results['service_down_action'] == 'drop' assert results['lb_method'] == 'round-robin' assert results['slow_ramp_time'] == 10 assert results['reselect_tries'] == 1