import logging from unittest import mock from little_boxes import activitypub as ap from little_boxes import content_helper from test_backend import InMemBackend logging.basicConfig(level=logging.DEBUG) def test_little_content_helper_simple(): back = InMemBackend() ap.use_backend(back) content, tags = content_helper.parse_markdown("hello") assert content == "

hello

" assert tags == [] def test_little_content_helper_linkify(): back = InMemBackend() ap.use_backend(back) content, tags = content_helper.parse_markdown("hello https://google.com") assert content.startswith("

hello hello @dev' "@microblog.pub

" ) assert tags == [ { "href": "https://microblog.pub", "name": "@dev@microblog.pub", "type": "Mention", } ] @mock.patch( "little_boxes.content_helper.get_actor_url", return_value="https://microblog.pub" ) def test_little_content_helper_tag(_): back = InMemBackend() ap.use_backend(back) content, tags = content_helper.parse_markdown("hello #activitypub") base_url = back.base_url() assert content == ( f'

hello

" ) assert tags == [ { "href": f"{base_url}/tags/activitypub", "name": "#activitypub", "type": "Hashtag", } ]