def test_create_virtual_server_with_port_translation_string_no(
            self, *args):
        set_module_args(
            dict(destination="10.10.10.10",
                 port_translation='no',
                 name="my-snat-pool",
                 partition="Common",
                 port="443",
                 state="present",
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

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

        # Override methods to force specific logic in the module to happen
        mm = ModuleManager(module=module)
        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['port_translation'] is False
    def test_create_virtual_server(self, *args):
        set_module_args(
            dict(all_profiles=[dict(name='http'),
                               dict(name='clientssl')],
                 description="Test Virtual Server",
                 destination="10.10.10.10",
                 name="my-snat-pool",
                 partition="Common",
                 port="443",
                 snat="Automap",
                 state="present",
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

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

        # Override methods to force specific logic in the module to happen
        mm = ModuleManager(module=module)
        mm.exists = Mock(return_value=False)
        mm.create_on_device = Mock(return_value=True)
        results = mm.exec_module()

        assert results['changed'] is True
    def test_create_virtual_server_with_port_translation_bool_false(self, *args):
        set_module_args(dict(
            destination="10.10.10.10",
            port_translation=False,
            name="my-snat-pool",
            partition="Common",
            password="******",
            port="443",
            server="localhost",
            state="present",
            user="******",
            validate_certs="no"
        ))

        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.exists = Mock(return_value=False)
        mm.create_on_device = Mock(return_value=True)
        results = mm.exec_module()

        assert results['changed'] is True
        assert results['port_translation'] is False
    def test_create_virtual_server_with_port_translation_string_no(self, *args):
        set_module_args(dict(
            destination="10.10.10.10",
            port_translation='no',
            name="my-snat-pool",
            partition="Common",
            password="******",
            port="443",
            server="localhost",
            state="present",
            user="******",
            validate_certs="no"
        ))

        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.exists = Mock(return_value=False)
        mm.create_on_device = Mock(return_value=True)
        results = mm.exec_module()

        assert results['changed'] is True
        assert results['port_translation'] is False
    def test_create_virtual_server(self, *args):
        set_module_args(dict(
            all_profiles=[
                dict(
                    name='http'
                ),
                dict(
                    name='clientssl'
                )
            ],
            description="Test Virtual Server",
            destination="10.10.10.10",
            name="my-snat-pool",
            partition="Common",
            password="******",
            port="443",
            server="localhost",
            snat="Automap",
            state="present",
            user="******",
            validate_certs="no"
        ))

        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.exists = Mock(return_value=False)
        mm.create_on_device = Mock(return_value=True)
        results = mm.exec_module()

        assert results['changed'] is True