def test_update_description_idempotent(self, *args):
        set_module_args(dict(
            name='test-route',
            password='******',
            server='localhost',
            user='******',
            state='present',
            description='asdasd'
        ))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            mutually_exclusive=self.spec.mutually_exclusive,
            supports_check_mode=self.spec.supports_check_mode
        )
        mm = ModuleManager(module=module)

        # Override methods to force specific logic in the module to happen
        current = Parameters(params=load_fixture('load_net_route_description.json'))
        mm.exists = Mock(return_value=True)
        mm.update_on_device = Mock(return_value=True)
        mm.read_current_from_device = Mock(return_value=current)
        results = mm.exec_module()

        # There is no assert for the description, because it should
        # not have changed
        assert results['changed'] is False
    def test_create_route_to_vlan(self, *args):
        set_module_args(dict(
            name='test-route',
            password='******',
            server='localhost',
            user='******',
            state='present',
            destination='10.10.10.10',
            vlan="test-vlan"
        ))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            mutually_exclusive=self.spec.mutually_exclusive,
            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['vlan'] == '/Common/test-vlan'
Example #3
0
    def test_create_with_route_domain(self, *args):
        set_module_args(
            dict(name='test-route',
                 password='******',
                 server='localhost',
                 user='******',
                 state='present',
                 destination='10.10.10.10',
                 netmask='255.255.255.255',
                 route_domain=1,
                 reject='yes'))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            mutually_exclusive=self.spec.mutually_exclusive,
            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['route_domain'] == 1
        assert results['destination'] == '10.10.10.10%1/32'
Example #4
0
    def test_update_description(self, *args):
        set_module_args(
            dict(name='test-route',
                 password='******',
                 server='localhost',
                 user='******',
                 state='present',
                 description='foo description'))

        client = AnsibleF5Client(
            argument_spec=self.spec.argument_spec,
            mutually_exclusive=self.spec.mutually_exclusive,
            supports_check_mode=self.spec.supports_check_mode,
            f5_product_name=self.spec.f5_product_name)
        mm = ModuleManager(client)

        # Override methods to force specific logic in the module to happen
        current = Parameters(load_fixture('load_net_route_description.json'))
        mm.exists = Mock(return_value=True)
        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['description'] == 'foo description'
Example #5
0
    def test_delete(self, *args):
        set_module_args(
            dict(name='test-route',
                 password='******',
                 server='localhost',
                 user='******',
                 state='absent'))

        module = AnsibleModule(
            argument_spec=self.spec.argument_spec,
            mutually_exclusive=self.spec.mutually_exclusive,
            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(side_effect=[True, False])
        mm.remove_from_device = Mock(return_value=True)
        results = mm.exec_module()

        assert results['changed'] is True
        assert 'description' not in results
Example #6
0
    def test_create_blackhole(self, *args):
        set_module_args(
            dict(name='test-route',
                 password='******',
                 server='localhost',
                 user='******',
                 state='present',
                 destination='10.10.10.10',
                 reject='yes'))

        client = AnsibleF5Client(
            argument_spec=self.spec.argument_spec,
            mutually_exclusive=self.spec.mutually_exclusive,
            supports_check_mode=self.spec.supports_check_mode,
            f5_product_name=self.spec.f5_product_name)
        mm = ModuleManager(client)

        # 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