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

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

        vm = V1Manager(client)
        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)
Example #2
0
    def test_ucs_absent_exists(self, *args):
        set_module_args(dict(
            ucs="/root/bigip.localhost.localdomain.ucs",
            server='localhost',
            password='******',
            user='******',
            state='absent'
        ))

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

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

        results = vm.exec_module()

        assert results['changed'] is True
Example #3
0
    def test_ucs_default_present(self, *args):
        set_module_args(
            dict(ucs="/root/bigip.localhost.localdomain.ucs",
                 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=True)

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

        results = vm.exec_module()

        assert results['changed'] is True