from activities.models import Hashtag
def test_hashtag_from_content():
assert Hashtag.hashtags_from_content("#hashtag") == ["hashtag"]
assert Hashtag.hashtags_from_content("a#hashtag") == []
assert Hashtag.hashtags_from_content("Text #with #hashtag in it") == [
"hashtag",
"with",
]
assert Hashtag.hashtags_from_content("#hashtag.") == ["hashtag"]
assert Hashtag.hashtags_from_content("More text\n#one # two ##three #hashtag!") == [
"hashtag",
"one",
"three",
]
assert Hashtag.hashtags_from_content("my #html loves entities") == ["html"]
assert Hashtag.hashtags_from_content("#tag") == ["tag"]
def test_linkify_hashtag():
linkify = Hashtag.linkify_hashtags
assert linkify("# hashtag") == "# hashtag"
assert (
linkify('Text')
== 'Text'
)
assert (
linkify("#HashTag") == '#HashTag'
)
assert (
linkify(
"""A longer text #bigContent
with #tags, linebreaks, and
maybe a few links
#allTheTags #AllTheTags #ALLTHETAGS"""
)
== """A longer text #bigContent
with #tags, linebreaks, and
maybe a few links
#allTheTags #AllTheTags #ALLTHETAGS"""
)