'Verify the output of a server task.'

def verify_server_task(self, task_name, options, contracts_default=False):

    log_string = options.get('log_string', '>    /dev/null')
    settings = options.get('settings', None)
    asset_settings = options.get('asset-settings', None)
    is_optimized = options.get('optimized', False)
    is_fast = options.get('fast', False)
    no_contracts = options.get('no-contracts', (not contracts_default))
    if (task_name == 'devstack'):
        system = options.get('system')
    elif (task_name == 'studio'):
        system = 'cms'
    else:
        system = 'lms'
    port = options.get('port', ('8000' if (system == 'lms') else '8001'))
    self.reset_task_messages()
    if (task_name == 'devstack'):
        args = [('studio' if (system == 'cms') else system)]
        if settings:
            args.append('--settings={settings}'.format(settings=settings))
        if asset_settings:
            args.append('--asset-settings={asset_settings}'.format(asset_settings=asset_settings))
        if is_optimized:
            args.append('--optimized')
        if is_fast:
            args.append('--fast')
        if no_contracts:
            args.append('--no-contracts')
        call_task('pavelib.servers.devstack', args=args)
    else:
        call_task('pavelib.servers.{task_name}'.format(task_name=task_name), options=options)
    expected_messages = options.get('expected_messages', [])
    expected_settings = (settings if settings else Env.DEVSTACK_SETTINGS)
    expected_asset_settings = (asset_settings if asset_settings else expected_settings)
    if is_optimized:
        expected_settings = 'devstack_optimized'
        expected_asset_settings = 'test_static_optimized'
    expected_collect_static = ((not is_fast) and (expected_settings != Env.DEVSTACK_SETTINGS))
    if (not is_fast):
        expected_messages.append(u'xmodule_assets    common/static/xmodule')
        expected_messages.append(u'install    npm_assets')
        expected_messages.append(EXPECTED_COFFEE_COMMAND.format(platform_root=self.platform_root))
        expected_messages.extend([c.format(settings=expected_asset_settings) for c in EXPECTED_PRINT_SETTINGS_COMMAND])
        expected_messages.append(EXPECTED_WEBPACK_COMMAND.format(node_env=('production' if (expected_asset_settings != Env.DEVSTACK_SETTINGS) else 'development'), static_root_lms=None, static_root_cms=None))
        expected_messages.extend(self.expected_sass_commands(system=system, asset_settings=expected_asset_settings))
    if expected_collect_static:
        expected_messages.append(EXPECTED_COLLECT_STATIC_COMMAND.format(system=system, asset_settings=expected_asset_settings, log_string=log_string))
    expected_run_server_command = EXPECTED_RUN_SERVER_COMMAND.format(system=system, settings=expected_settings, port=port)
    if (not no_contracts):
        expected_run_server_command += '    --contracts'
    expected_messages.append(expected_run_server_command)
    self.assertEquals(self.task_messages, expected_messages)
