def check_queue(queue, config):
    """
    Check length and policy of a single queue
    :param queue: Queue form rabbit
    :param config: Desired queue state
    :return: length of a queue and lists of warnings and errors
    """
    warnings = []
    errors = []
    length = queue['messages_ready']

    if length > config['critical']:
        errors.append(length)
    elif length > config['warning']:
        warnings.append(length)

    policy = config.get('policy')
    queue_policy = queue.get('effective_policy_definition')
    if policy and policy != queue_policy:
        errors.append('Wrong queue policy')

    return length, warnings, errors