def test_update_generic_router(self, *args):
        set_module_args(
            dict(name='messagerouter',
                 use_local_connection='no',
                 mirror='yes',
                 routes=['/Common/example'],
                 provider=dict(server='localhost',
                               password='******',
                               user='******')))

        current = ApiParameters(
            params=load_fixture('load_generic_router.json'))

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

        # Override methods in the specific type of manager
        gm = GenericModuleManager(module=module)
        gm.exists = Mock(return_value=True)
        gm.update_on_device = Mock(return_value=True)
        gm.read_current_from_device = Mock(return_value=current)

        mm = ModuleManager(module=module)
        mm.version_less_than_14 = Mock(return_value=False)
        mm.get_manager = Mock(return_value=gm)

        results = mm.exec_module()

        assert results['changed'] is True
        assert results['use_local_connection'] == 'no'
        assert results['mirror'] == 'yes'
        assert results['routes'] == ['/Common/example']
    def test_create_generic_router(self, *args):
        set_module_args(dict(
            name='foo',
            partition='foobar',
            description='my description',
            ignore_client_port='no',
            inherited_traffic_group='yes',
            use_local_connection='no',
            max_pending_bytes=20000,
            max_pending_messages=300,
            max_retries=32,
            mirror='yes',
            mirrored_msg_sweeper_interval=3000,
            routes=['test1', 'test2'],
            traffic_group='footraffic',
            provider=dict(
                server='localhost',
                password='******',
                user='******'
            )
        ))

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

        # Override methods in the specific type of manager
        gm = GenericModuleManager(module=module)
        gm.exists = Mock(return_value=False)
        gm.create_on_device = Mock(return_value=True)

        mm = ModuleManager(module=module)
        mm.version_less_than_14 = Mock(return_value=False)
        mm.get_manager = Mock(return_value=gm)

        results = mm.exec_module()

        assert results['changed'] is True
        assert results['description'] == 'my description'
        assert results['ignore_client_port'] == 'no'
        assert results['inherited_traffic_group'] == 'yes'
        assert results['use_local_connection'] == 'no'
        assert results['max_pending_bytes'] == 20000
        assert results['max_pending_messages'] == 300
        assert results['max_retries'] == 32
        assert results['mirror'] == 'yes'
        assert results['mirrored_msg_sweeper_interval'] == 3000
        assert results['traffic_group'] == '/Common/footraffic'
        assert results['routes'] == ['/foobar/test1', '/foobar/test2']