示例#1
0
def assert_success(messages=None):
    """Asserts that there is 1 or more successful messages, no errors. If no messages
    are passed in, they will be retrieved from the UI."""

    all_messages = messages or get_messages()
    errors = [error.message for error in filter(is_error, all_messages)]
    if not all_messages:
        raise FlashMessageException('No flash messages found')
    elif errors:
        raise FlashMessageException(', '.join(errors))
    else:
        return all_messages
示例#2
0
def assert_message_match(m):
    """ Asserts that a message matches a specific string."""
    logger.debug('Asserting flash message match for %s', m)
    if not any([fm.message == m for fm in get_messages()]):
        logger.debug(' No match found in...%s', get_messages())
        raise FlashMessageException(
            "No matching flash message for '{}'".format(m))
示例#3
0
def assert_success_message(m):
    """Asserts that there are no errors and a (green) info message
    matches the given string."""
    messages = get_messages()
    assert_no_errors(messages)
    if not any([(fm.message == m and (fm.level in {"info", "success"}))
                for fm in messages]):
        raise FlashMessageException(
            "No matching info flash message for '{}', instead got {}".format(
                m, messages))
示例#4
0
def assert_no_errors(messages=None):
    """Asserts that there are no current Error messages. If no messages
    are passed in, they will be retrieved from the UI."""

    all_messages = messages or get_messages()
    errors = [error.message for error in filter(is_error, all_messages)]
    if errors:
        raise FlashMessageException(', '.join(errors))
    else:
        return all_messages
示例#5
0
def assert_message_contain(m):
    """ Asserts that a message contains a specific string """
    if not any([m in fm.message for fm in get_messages()]):
        raise FlashMessageException("No flash message contains '%s'" % m)