Exemplo n.º 1
0
    def test_update_hostname(self, *args):
        set_module_args(dict(
            hostname='foo2.internal.com',
            password='******',
            server='localhost',
            user='******'
        ))

        # Configure the parameters that would be returned by querying the
        # remote device
        current = ApiParameters(
            params=dict(
                hostname='foo.internal.com'
            )
        )
        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
        mm = ModuleManager(module=module)
        mm.update_on_device = Mock(return_value=True)
        mm.read_current_from_device = Mock(return_value=current)

        results = mm.exec_module()

        assert results['changed'] is True
        assert results['hostname'] == 'foo2.internal.com'
Exemplo n.º 2
0
    def test_update_hostname(self, *args):
        set_module_args(
            dict(hostname='foo2.internal.com',
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        # Configure the parameters that would be returned by querying the
        # remote device
        current = ApiParameters(params=dict(hostname='foo.internal.com'))
        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
        mm = ModuleManager(module=module)
        mm.update_on_device = Mock(return_value=True)
        mm.read_current_from_device = Mock(return_value=current)

        results = mm.exec_module()

        assert results['changed'] is True
        assert results['hostname'] == 'foo2.internal.com'