# Path: project/tests/base.py
# class UtilsTestCase(BaseTestCase):
#     """Default utils test case for every utils/<file>.py"""
#     pass
# 
# Path: project/utils/flash.py
# def flash(message, category='default'):
#     """
#     For the given message, if html is present, add bootstrap .alert-link class to all links
#     """
#     if message.startswith('<p>') and message.endswith('</p>'):
#         message = BeautifulSoup(message, "lxml")
#         for a in message.find_all("a"):
#             if not a.get('class'):
#                 a.attrs.update({'class': []})
#             a['class'].extend(ALERT_LINK_CLASS)
#         message = str(message)
# 
#     FLASH(message, category)
# 
# def success(message):
#     flash(message, category="success")
# 
# def warning(message):
#     flash(message, category="warning")
# 
# def info(message):
#     flash(message, category="info")
# 
# def danger(message):
#     flash(message, category="danger")
# 
# ALERT_LINK_CLASS = ['alert-link']


from flask import get_flashed_messages
from project.tests.base import UtilsTestCase
from project.utils.flash import flash, success, warning, info, danger, ALERT_LINK_CLASS
# !/usr/bin/python
# -*- coding: utf-8 -*-



class FlashUtilsTestCase(UtilsTestCase):

    def assert_flashes(self, expected_message, expected_category='message'):
        flashed_messages = get_flashed_messages(with_categories=True)
        for category, message in flashed_messages:
            if category == expected_category:
                self.assertEqual(message, expected_message)
                return

# Path: project/tests/base.py
# class UtilsTestCase(BaseTestCase):
#     """Default utils test case for every utils/<file>.py"""
#     pass
# 
# Path: project/utils/flash.py
# def flash(message, category='default'):
#     """
#     For the given message, if html is present, add bootstrap .alert-link class to all links
#     """
#     if message.startswith('<p>') and message.endswith('</p>'):
#         message = BeautifulSoup(message, "lxml")
#         for a in message.find_all("a"):
#             if not a.get('class'):
#                 a.attrs.update({'class': []})
#             a['class'].extend(ALERT_LINK_CLASS)
#         message = str(message)
# 
#     FLASH(message, category)
# 
# def success(message):
#     flash(message, category="success")
# 
# def warning(message):
#     flash(message, category="warning")
# 
# def info(message):
#     flash(message, category="info")
# 
# def danger(message):
#     flash(message, category="danger")
# 
# ALERT_LINK_CLASS = ['alert-link']


# Path: project/utils/tests/test_flash.py
from flask import get_flashed_messages
from project.tests.base import UtilsTestCase
from project.utils.flash import flash, success, warning, info, danger, ALERT_LINK_CLASS

# !/usr/bin/python
# -*- coding: utf-8 -*-



class FlashUtilsTestCase(UtilsTestCase):

    def assert_flashes(self, expected_message, expected_category='message'):
        flashed_messages = get_flashed_messages(with_categories=True)
        for category, message in flashed_messages:
            if category == expected_category:
                self.assertEqual(message, expected_message)
                return

        raise AssertionError("nothing flashed")