Пример #1
0
    def test_ucs_absent_fails(self, *args):
        set_module_args(dict(
            ucs="/root/bigip.localhost.localdomain.ucs",
            state='absent',
            provider=dict(
                server='localhost',
                password='******',
                user='******'
            )
        ))

        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.is_version_v1 = Mock(return_value=False)

        vm = V1Manager(module=module)
        vm.remove_from_device = Mock(return_value=True)
        vm.exists = Mock(side_effect=[True, True])

        with pytest.raises(F5ModuleError) as ex:
            vm.exec_module()
        assert 'Failed to delete' in str(ex.value)
Пример #2
0
    def test_ucs_absent_fails(self, *args):
        set_module_args(dict(
            ucs="/root/bigip.localhost.localdomain.ucs",
            server='localhost',
            password='******',
            user='******',
            state='absent'
        ))

        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.is_version_v1 = Mock(return_value=False)

        vm = V1Manager(module=module)
        vm.remove_from_device = Mock(return_value=True)
        vm.exists = Mock(side_effect=[True, True])

        with pytest.raises(F5ModuleError) as ex:
            vm.exec_module()
        assert 'Failed to delete' in str(ex.value)
Пример #3
0
    def test_ucs_absent_exists(self, *args):
        set_module_args(dict(
            ucs="/root/bigip.localhost.localdomain.ucs",
            state='absent',
            provider=dict(
                server='localhost',
                password='******',
                user='******'
            )
        ))

        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.is_version_v1 = Mock(return_value=False)

        vm = V1Manager(module=module)
        vm.remove_from_device = Mock(return_value=True)
        vm.exists = Mock(side_effect=[True, False])

        results = vm.exec_module()

        assert results['changed'] is True
Пример #4
0
    def test_ucs_absent_exists(self, *args):
        set_module_args(dict(
            ucs="/root/bigip.localhost.localdomain.ucs",
            server='localhost',
            password='******',
            user='******',
            state='absent'
        ))

        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.is_version_v1 = Mock(return_value=False)

        vm = V1Manager(module=module)
        vm.remove_from_device = Mock(return_value=True)
        vm.exists = Mock(side_effect=[True, False])

        results = vm.exec_module()

        assert results['changed'] is True
Пример #5
0
    def test_ucs_installed(self, *args):
        set_module_args(
            dict(ucs="/root/bigip.localhost.localdomain.ucs",
                 server='localhost',
                 password='******',
                 user='******',
                 state='installed'))

        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.is_version_v1 = Mock(return_value=False)

        vm = V2Manager(module=module)
        vm.create_on_device = Mock(return_value=True)
        vm.exists = Mock(return_value=True)
        vm.install_on_device = Mock(return_value=True)

        results = vm.exec_module()

        assert results['changed'] is True