Пример #1
0
    def test_update_vlan_tag_interface(self, *args):
        set_module_args(
            dict(
                name='somevlan',
                tagged_interface=['2.1'],
                server='localhost',
                password='******',
                user='******',
                partition='Common',
            ))

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

        # Override methods to force specific logic in the module to happen
        mm = ModuleManager(client)

        current = ApiParameters(load_fixture('load_vlan.json'))

        mm.update_on_device = Mock(return_value=True)
        mm.exists = Mock(return_value=True)
        mm.read_current_from_device = Mock(return_value=current)

        results = mm.exec_module()

        assert results['changed'] is True
        assert results['tagged_interfaces'] == ['2.1']
Пример #2
0
    def test_update_vlan_description(self, *args):
        set_module_args(
            dict(
                name='somevlan',
                description='changed_that',
                server='localhost',
                password='******',
                user='******',
                partition='Common',
            ))

        client = AnsibleF5Client(
            argument_spec=self.spec.argument_spec,
            supports_check_mode=self.spec.supports_check_mode,
            f5_product_name=self.spec.f5_product_name)
        ifcs = self.loaded_vlan_ifc_tag
        # Override methods to force specific logic in the module to happen
        with patch.object(Parameters, '_get_interfaces_from_device') as obj:
            obj.return_value = self.loaded_ifcs
            mm = ModuleManager(client)

            current = (Parameters(
                load_fixture('update_vlan_description.json')), ifcs)

            mm.update_on_device = Mock(return_value=True)
            mm.exists = 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'] == 'changed_that'
Пример #3
0
    def test_update_vlan_description(self, *args):
        set_module_args(
            dict(
                name='somevlan',
                description='changed_that',
                server='localhost',
                password='******',
                user='******',
                partition='Common',
            ))

        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)

        current = ApiParameters(
            params=load_fixture('update_vlan_description.json'))

        mm.update_on_device = Mock(return_value=True)
        mm.exists = 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'] == 'changed_that'