Пример #1
0
    def test_update_settings(self, *args):
        set_module_args(
            dict(cache='disable',
                 forwarders=['12.12.12.12', '13.13.13.13'],
                 ip_version=4,
                 name_servers=['10.10.10.10', '11.11.11.11'],
                 search=['14.14.14.14', '15.15.15.15'],
                 server='localhost',
                 user='******',
                 password='******'))

        # Configure the parameters that would be returned by querying the
        # remote device
        current = Parameters(dict(cache='enable'))

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

        # Override methods to force specific logic in the module to happen
        mm.update_on_device = Mock(return_value=True)
        mm.read_current_from_device = Mock(return_value=current)

        results = mm.exec_module()

        assert results['changed'] is True
    def test_module_parameters(self):
        args = dict(cache='disable',
                    ip_version=4,
                    name_servers=['10.10.10.10', '11.11.11.11'],
                    search=['14.14.14.14', '15.15.15.15'],
                    server='localhost',
                    user='******',
                    password='******')
        p = Parameters(params=args)
        assert p.cache == 'disable'
        assert p.name_servers == ['10.10.10.10', '11.11.11.11']
        assert p.search == ['14.14.14.14', '15.15.15.15']

        # BIG-IP considers "ipv4" to be an empty value
        assert p.ip_version == ''
Пример #3
0
 def test_ensure_forwards_raises_exception(self):
     args = dict(forwarders=['12.12.12.12', '13.13.13.13'], )
     p = Parameters(args)
     with pytest.raises(F5ModuleError) as ex:
         foo = p.forwarders
     assert 'The modifying of forwarders is not supported' in str(ex)
Пример #4
0
 def test_ipv6_parameter(self):
     args = dict(ip_version=6)
     p = Parameters(args)
     assert p.ip_version == 'options inet6'