def test_create_reuse_node_with_name(self, *args):
        # Configure the arguments that would be sent to the Ansible module
        set_module_args(
            dict(pool='my-pool',
                 fqdn='foo.bar.com',
                 port=2345,
                 state='present',
                 partition='Common',
                 reuse_nodes=True,
                 provider=dict(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,
            mutually_exclusive=self.spec.mutually_exclusive,
            required_one_of=self.spec.required_one_of,
        )
        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'
    def test_create_aggregate_pool_members(self, *args):
        set_module_args(
            dict(pool='fake_pool',
                 aggregate=[
                     dict(
                         name='my-name',
                         host="1.1.1.1",
                         port=1234,
                         state='present',
                         partition='Common',
                         reuse_nodes=True,
                         fqdn_auto_populate=False,
                     ),
                     dict(
                         name='my-name2',
                         fqdn='google.com',
                         port=2423,
                         state='present',
                         partition='Common',
                         fqdn_auto_populate=True,
                         reuse_nodes=True,
                     )
                 ],
                 provider=dict(password='******',
                               server='localhost',
                               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