# 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

    def setUp(self):
        super(FlashUtilsTestCase, self).setUp()
        self.simple_message = "This is a simpple flash message"
        self.html_message = '<p><a>This is <b>html</b> <strong>flash</strong>message</a></p>'
        self.html_w_a_class_message = (
            '<html><body><p><a class="{}">This is <b>html</b> <strong>flash</strong>message</a></p></body></html>'
            ''.format(ALERT_LINK_CLASS[0])
        )

    def test_flash_different_categories(self):
        """
        Ensure all 4 categories work properly
        """
        success(self.simple_message)
        warning(self.simple_message)
        info(self.simple_message)
        danger(self.simple_message)
        self.assert_flashes(self.simple_message, 'success')
        self.assert_flashes(self.simple_message, 'warning')
        self.assert_flashes(self.simple_message, 'info')
        self.assert_flashes(self.simple_message, 'danger')

    def test_flash_behaviour_with_html(self):
        """
        Ensure default flash works with html input
        """
        flash(self.html_message)
        self.assert_flashes(self.html_w_a_class_message, 'default')


# 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


    def setUp(self):
        super(FlashUtilsTestCase, self).setUp()
        self.simple_message = "This is a simpple flash message"
        self.html_message = '<p><a>This is <b>html</b> <strong>flash</strong>message</a></p>'
        self.html_w_a_class_message = (
            '<html><body><p><a class="{}">This is <b>html</b> <strong>flash</strong>message</a></p></body></html>'
            ''.format(ALERT_LINK_CLASS[0])
        )

    def test_flash_different_categories(self):
        """
        Ensure all 4 categories work properly
        """
        success(self.simple_message)
        warning(self.simple_message)
        info(self.simple_message)
        danger(self.simple_message)
        self.assert_flashes(self.simple_message, 'success')
        self.assert_flashes(self.simple_message, 'warning')
        self.assert_flashes(self.simple_message, 'info')
        self.assert_flashes(self.simple_message, 'danger')

    def test_flash_behaviour_with_html(self):
        """
        Ensure default flash works with html input
        """
        flash(self.html_message)
        self.assert_flashes(self.html_w_a_class_message, 'default')


        flash(self.html_w_a_class_message)