def test_create_name_is_address_with_session_and_monitor_disabled( self, *args): # Configure the arguments that would be sent to the Ansible module set_module_args( dict(pool='my-pool', name='10.10.10.10', port=2345, state='present', monitor_state='disabled', session_state='disabled', partition='Common', password='******', server='localhost', user='******')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode) mm = ModuleManager(module=module) # Override methods to force specific logic in the module to happen mm.exists = Mock(return_value=False) mm.create_on_device = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True assert results['fqdn_auto_populate'] is False assert results['address'] == '10.10.10.10' assert results['state'] == 'forced_offline'
def test_create_reuse_node_with_fqdn_auto_populate(self, *args): # Configure the arguments that would be sent to the Ansible module set_module_args( dict(pool='my-pool', name='my-name', port=2345, state='present', partition='Common', reuse_nodes=True, fqdn_auto_populate=False, password='******', server='localhost', user='******')) current_node = NodeApiParameters( params=load_fixture('load_net_node_with_fqdn.json')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode) mm = ModuleManager(module=module) # Override methods to force specific logic in the module to happen mm.exists = Mock(return_value=False) mm.create_on_device = Mock(return_value=True) mm.read_current_node_from_device = Mock(return_value=current_node) results = mm.exec_module() assert results['changed'] is True assert results['fqdn_auto_populate'] is True assert results['fqdn'] == 'foo.bar.com' assert results['state'] == 'present'