# Path: dwitter/templatetags/insert_magic_links.py
# @register.filter(is_safe=True)
# def insert_magic_links(text):
#     text = re.sub(
#         r'(?:^|(?<=\s))'                                        # start of string or whitespace
#         r'/?'                                                   # optional /
#         r'(?P<text>'                                            # capture original pattern
#         r'[^a-zA-Z\d]?d/(?P<dweet_id>\d+)[^a-zA-Z]?'            # dweet reference
#         r'|'                                                    # or
#         r'[^a-zA-Z\d]?u/(?P<username>[\w.@+-]+)[^a-zA-Z\d]?)'   # user reference
#         r'(?=$|\s|#)',                                       # end of string, whitespace or hashtag
#         user_dweet_to_link,
#         text
#     )
#     text = re.sub(
#         r'(?P<text>'                                            # capture original pattern
#         # (?:^|\s)    # go to the start of the line or the next space
#         # (?=\S*#)    # lookahead to see is there a '#' after a bunch of non-whitespace characters?
#         # (?!\S*:)    # lookahead to check aren't any ':' characters there
#         # (otherwise it's likely an anchor)
#         # \S*#        # skip any of the characters leading up to the '#'
#         # then do the hashtag grouping that was there before:
#         # (?P<hashtag>[_a-zA-Z][_a-zA-Z\d]*)
#         r'(?:^|\s)(?=\S*#)(?!\S*:)\S*#(?P<hashtag>[_a-zA-Z][_a-zA-Z\d]*))',
#         hashtag_to_link,
#         text
#     )
#     return text


from django.test import TestCase
from dwitter.templatetags.insert_magic_links import insert_magic_links


class DweetTestCase(TestCase):
    def test_insert_magic_links_bypasses_html(self):
        self.assertEqual(
            'prefix <h1>content</h1> suffix',

# Path: dwitter/templatetags/insert_magic_links.py
# @register.filter(is_safe=True)
# def insert_magic_links(text):
#     text = re.sub(
#         r'(?:^|(?<=\s))'                                        # start of string or whitespace
#         r'/?'                                                   # optional /
#         r'(?P<text>'                                            # capture original pattern
#         r'[^a-zA-Z\d]?d/(?P<dweet_id>\d+)[^a-zA-Z]?'            # dweet reference
#         r'|'                                                    # or
#         r'[^a-zA-Z\d]?u/(?P<username>[\w.@+-]+)[^a-zA-Z\d]?)'   # user reference
#         r'(?=$|\s|#)',                                       # end of string, whitespace or hashtag
#         user_dweet_to_link,
#         text
#     )
#     text = re.sub(
#         r'(?P<text>'                                            # capture original pattern
#         # (?:^|\s)    # go to the start of the line or the next space
#         # (?=\S*#)    # lookahead to see is there a '#' after a bunch of non-whitespace characters?
#         # (?!\S*:)    # lookahead to check aren't any ':' characters there
#         # (otherwise it's likely an anchor)
#         # \S*#        # skip any of the characters leading up to the '#'
#         # then do the hashtag grouping that was there before:
#         # (?P<hashtag>[_a-zA-Z][_a-zA-Z\d]*)
#         r'(?:^|\s)(?=\S*#)(?!\S*:)\S*#(?P<hashtag>[_a-zA-Z][_a-zA-Z\d]*))',
#         hashtag_to_link,
#         text
#     )
#     return text


# Path: dwitter/tests/templatetags/test_insert_magic_links.py
from django.test import TestCase
from dwitter.templatetags.insert_magic_links import insert_magic_links



class DweetTestCase(TestCase):
    def test_insert_magic_links_bypasses_html(self):
        self.assertEqual(
            'prefix <h1>content</h1> suffix',

            insert_magic_links('prefix <h1>content</h1> suffix')