def test_bigiq_version_raises(self):
        set_module_args(
            dict(name='foo',
                 description='my description',
                 service_environment='bar',
                 servers=[
                     dict(address='1.2.3.4', port=8080),
                     dict(address='5.6.7.8', port=8000)
                 ],
                 inbound_virtual=dict(address='2.2.2.2',
                                      netmask='255.255.255.255',
                                      port=80),
                 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)

        msg = 'Module supports only BIGIQ version 6.0.x or lower.'
        # Override methods to force specific logic in the module to happen
        mm = ModuleManager(module=module)

        with pytest.raises(F5ModuleError) as err:
            mm.exec_module()
        assert str(err.value) == msg
Пример #2
0
    def test_create(self, *args):
        set_module_args(dict(
            name='foo',
            description='my description',
            service_environment='bar',
            servers=[
                dict(
                    address='1.2.3.4',
                    port=8080
                ),
                dict(
                    address='5.6.7.8',
                    port=8000
                )
            ],
            inbound_virtual=dict(
                address='2.2.2.2',
                netmask='255.255.255.255',
                port=80
            ),
            redirect_virtual=dict(
                address='3.3.3.3',
                netmask='255.255.255.255',
                port=80
            ),
            domain_names=[
                'foo.baz.com',
                'bar.baz.com'
            ],
            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.check_bigiq_version = Mock(return_value=True)
        mm.has_no_service_environment = Mock(return_value=False)
        mm.wait_for_apply_template_task = Mock(return_value=True)

        mm.create_on_device = Mock(return_value=True)
        mm.exists = Mock(side_effect=[False, True])

        results = mm.exec_module()

        assert results['changed'] is True
        assert results['description'] == 'my description'