Beispiel #1
0
    def test_reject_parameter_types(self):
        # boolean true
        args = dict(reject=True)
        p = Parameters(args)
        self.assertTrue(p.reject)

        # boolean false
        args = dict(reject=False)
        p = Parameters(args)
        self.assertFalse(p.reject)

        # string
        args = dict(reject="yes")
        p = Parameters(args)
        self.assertTrue(p.reject)

        # integer
        args = dict(reject=1)
        p = Parameters(args)
        self.assertTrue(p.reject)

        # none
        args = dict(reject=None)
        p = Parameters(args)
        self.assertFalse(p.reject)
    def test_reject_parameter_types(self):
        # boolean true
        args = dict(reject=True)
        p = Parameters(params=args)
        assert p.reject is True

        # boolean false
        args = dict(reject=False)
        p = Parameters(params=args)
        assert p.reject is None

        # string
        args = dict(reject="yes")
        p = Parameters(params=args)
        assert p.reject is True

        # integer
        args = dict(reject=1)
        p = Parameters(params=args)
        assert p.reject is True

        # none
        args = dict(reject=None)
        p = Parameters(params=args)
        assert p.reject is None
Beispiel #3
0
    def test_destination_parameter_types(self):
        # ip address
        args = dict(destination="10.10.10.10")
        p = Parameters(args)
        assert p.destination == '10.10.10.10/32'

        # cidr address
        args = dict(destination="10.10.10.10/32")
        p = Parameters(args)
        assert p.destination == '10.10.10.10/32'

        # netmask
        args = dict(destination="10.10.10.10/255.255.255.255")
        p = Parameters(args)
        assert p.destination == '10.10.10.10/32'
    def test_update_description_idempotent(self, *args):
        set_module_args(dict(
            name='test-route',
            password='******',
            server='localhost',
            user='******',
            state='present',
            description='asdasd'
        ))

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

        # Override methods to force specific logic in the module to happen
        current = Parameters(params=load_fixture('load_net_route_description.json'))
        mm.exists = Mock(return_value=True)
        mm.update_on_device = Mock(return_value=True)
        mm.read_current_from_device = Mock(return_value=current)
        results = mm.exec_module()

        # There is no assert for the description, because it should
        # not have changed
        assert results['changed'] is False
Beispiel #5
0
    def test_update_description(self, *args):
        set_module_args(
            dict(name='test-route',
                 password='******',
                 server='localhost',
                 user='******',
                 state='present',
                 description='foo description'))

        client = AnsibleF5Client(
            argument_spec=self.spec.argument_spec,
            mutually_exclusive=self.spec.mutually_exclusive,
            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
        current = Parameters(load_fixture('load_net_route_description.json'))
        mm.exists = Mock(return_value=True)
        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
        assert results['description'] == 'foo description'
Beispiel #6
0
 def test_api_parameters(self):
     args = dict(
         tmInterface="foo",
         gw="10.10.10.10"
     )
     p = Parameters.from_api(args)
     self.assertEqual(p.vlan, '/Common/foo')
     self.assertEqual(p.gateway_address, '10.10.10.10')
Beispiel #7
0
 def test_module_parameters(self):
     args = dict(
         vlan="foo",
         gateway_address="10.10.10.10"
     )
     p = Parameters(args)
     self.assertEqual(p.vlan, '/Common/foo')
     self.assertEqual(p.gateway_address, '10.10.10.10')
 def test_api_parameters(self):
     args = dict(
         tmInterface="foo",
         gw="10.10.10.10"
     )
     p = Parameters(params=args)
     assert p.vlan == '/Common/foo'
     assert p.gateway_address == '10.10.10.10'
 def test_module_parameters(self):
     args = dict(
         vlan="foo",
         gateway_address="10.10.10.10"
     )
     p = Parameters(params=args)
     assert p.vlan == '/Common/foo'
     assert p.gateway_address == '10.10.10.10'
 def test_vlan_with_partition(self):
     args = dict(
         vlan="/Common/foo",
         gateway_address="10.10.10.10"
     )
     p = Parameters(params=args)
     assert p.vlan == '/Common/foo'
     assert p.gateway_address == '10.10.10.10'