refactor: Rename bugdown_convert to markdown_convert.

This commit is part of series of commits aimed at renaming bugdown to
markdown.
This commit is contained in:
Mohit Gupta 2020-06-27 02:56:54 +05:30 committed by Tim Abbott
parent 44d68c1840
commit 3b33e85baa
1 changed files with 62 additions and 62 deletions

View File

@ -186,7 +186,7 @@ class FencedBlockPreprocessorTest(TestCase):
lines = processor.run(markdown_input) lines = processor.run(markdown_input)
self.assertEqual(lines, expected) self.assertEqual(lines, expected)
def bugdown_convert(content: str) -> str: def markdown_convert(content: str) -> str:
return convert( return convert(
content=content, content=content,
message_realm=get_realm('zulip'), message_realm=get_realm('zulip'),
@ -410,7 +410,7 @@ class BugdownTest(ZulipTestCase):
msg = Message(sender=user_profile, sending_client=get_client("test")) msg = Message(sender=user_profile, sending_client=get_client("test"))
converted = render_markdown(msg, test['input']) converted = render_markdown(msg, test['input'])
else: else:
converted = bugdown_convert(test['input']) converted = markdown_convert(test['input'])
self.assertEqual(converted, test['expected_output']) self.assertEqual(converted, test['expected_output'])
@ -430,12 +430,12 @@ class BugdownTest(ZulipTestCase):
match = replaced(reference, url, phrase=inline_url) match = replaced(reference, url, phrase=inline_url)
except TypeError: except TypeError:
match = reference match = reference
converted = bugdown_convert(inline_url) converted = markdown_convert(inline_url)
self.assertEqual(match, converted) self.assertEqual(match, converted)
def test_inline_file(self) -> None: def test_inline_file(self) -> None:
msg = 'Check out this file file:///Volumes/myserver/Users/Shared/pi.py' msg = 'Check out this file file:///Volumes/myserver/Users/Shared/pi.py'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>Check out this file <a href="file:///Volumes/myserver/Users/Shared/pi.py">file:///Volumes/myserver/Users/Shared/pi.py</a></p>') self.assertEqual(converted, '<p>Check out this file <a href="file:///Volumes/myserver/Users/Shared/pi.py">file:///Volumes/myserver/Users/Shared/pi.py</a></p>')
clear_state_for_testing() clear_state_for_testing()
@ -447,49 +447,49 @@ class BugdownTest(ZulipTestCase):
def test_inline_bitcoin(self) -> None: def test_inline_bitcoin(self) -> None:
msg = 'To bitcoin:1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa or not to bitcoin' msg = 'To bitcoin:1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa or not to bitcoin'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>To <a href="bitcoin:1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa">bitcoin:1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa</a> or not to bitcoin</p>') self.assertEqual(converted, '<p>To <a href="bitcoin:1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa">bitcoin:1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa</a> or not to bitcoin</p>')
def test_inline_youtube(self) -> None: def test_inline_youtube(self) -> None:
msg = 'Check out the debate: http://www.youtube.com/watch?v=hx1mjT73xYE' msg = 'Check out the debate: http://www.youtube.com/watch?v=hx1mjT73xYE'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>Check out the debate: <a href="http://www.youtube.com/watch?v=hx1mjT73xYE">http://www.youtube.com/watch?v=hx1mjT73xYE</a></p>\n<div class="youtube-video message_inline_image"><a data-id="hx1mjT73xYE" href="http://www.youtube.com/watch?v=hx1mjT73xYE"><img src="https://i.ytimg.com/vi/hx1mjT73xYE/default.jpg"></a></div>') self.assertEqual(converted, '<p>Check out the debate: <a href="http://www.youtube.com/watch?v=hx1mjT73xYE">http://www.youtube.com/watch?v=hx1mjT73xYE</a></p>\n<div class="youtube-video message_inline_image"><a data-id="hx1mjT73xYE" href="http://www.youtube.com/watch?v=hx1mjT73xYE"><img src="https://i.ytimg.com/vi/hx1mjT73xYE/default.jpg"></a></div>')
msg = 'http://www.youtube.com/watch?v=hx1mjT73xYE' msg = 'http://www.youtube.com/watch?v=hx1mjT73xYE'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p><a href="http://www.youtube.com/watch?v=hx1mjT73xYE">http://www.youtube.com/watch?v=hx1mjT73xYE</a></p>\n<div class="youtube-video message_inline_image"><a data-id="hx1mjT73xYE" href="http://www.youtube.com/watch?v=hx1mjT73xYE"><img src="https://i.ytimg.com/vi/hx1mjT73xYE/default.jpg"></a></div>') self.assertEqual(converted, '<p><a href="http://www.youtube.com/watch?v=hx1mjT73xYE">http://www.youtube.com/watch?v=hx1mjT73xYE</a></p>\n<div class="youtube-video message_inline_image"><a data-id="hx1mjT73xYE" href="http://www.youtube.com/watch?v=hx1mjT73xYE"><img src="https://i.ytimg.com/vi/hx1mjT73xYE/default.jpg"></a></div>')
msg = 'https://youtu.be/hx1mjT73xYE' msg = 'https://youtu.be/hx1mjT73xYE'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p><a href="https://youtu.be/hx1mjT73xYE">https://youtu.be/hx1mjT73xYE</a></p>\n<div class="youtube-video message_inline_image"><a data-id="hx1mjT73xYE" href="https://youtu.be/hx1mjT73xYE"><img src="https://i.ytimg.com/vi/hx1mjT73xYE/default.jpg"></a></div>') self.assertEqual(converted, '<p><a href="https://youtu.be/hx1mjT73xYE">https://youtu.be/hx1mjT73xYE</a></p>\n<div class="youtube-video message_inline_image"><a data-id="hx1mjT73xYE" href="https://youtu.be/hx1mjT73xYE"><img src="https://i.ytimg.com/vi/hx1mjT73xYE/default.jpg"></a></div>')
msg = 'https://www.youtube.com/playlist?list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo' msg = 'https://www.youtube.com/playlist?list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo'
not_converted = bugdown_convert(msg) not_converted = markdown_convert(msg)
self.assertEqual(not_converted, '<p><a href="https://www.youtube.com/playlist?list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo">https://www.youtube.com/playlist?list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo</a></p>') self.assertEqual(not_converted, '<p><a href="https://www.youtube.com/playlist?list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo">https://www.youtube.com/playlist?list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo</a></p>')
msg = 'https://www.youtube.com/playlist?v=O5nskjZ_GoI&list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo' msg = 'https://www.youtube.com/playlist?v=O5nskjZ_GoI&list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p><a href="https://www.youtube.com/playlist?v=O5nskjZ_GoI&amp;list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo">https://www.youtube.com/playlist?v=O5nskjZ_GoI&amp;list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo</a></p>\n<div class="youtube-video message_inline_image"><a data-id="O5nskjZ_GoI" href="https://www.youtube.com/playlist?v=O5nskjZ_GoI&amp;list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo"><img src="https://i.ytimg.com/vi/O5nskjZ_GoI/default.jpg"></a></div>') self.assertEqual(converted, '<p><a href="https://www.youtube.com/playlist?v=O5nskjZ_GoI&amp;list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo">https://www.youtube.com/playlist?v=O5nskjZ_GoI&amp;list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo</a></p>\n<div class="youtube-video message_inline_image"><a data-id="O5nskjZ_GoI" href="https://www.youtube.com/playlist?v=O5nskjZ_GoI&amp;list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo"><img src="https://i.ytimg.com/vi/O5nskjZ_GoI/default.jpg"></a></div>')
msg = 'http://www.youtube.com/watch_videos?video_ids=nOJgD4fcZhI,i96UO8-GFvw' msg = 'http://www.youtube.com/watch_videos?video_ids=nOJgD4fcZhI,i96UO8-GFvw'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p><a href="http://www.youtube.com/watch_videos?video_ids=nOJgD4fcZhI,i96UO8-GFvw">http://www.youtube.com/watch_videos?video_ids=nOJgD4fcZhI,i96UO8-GFvw</a></p>\n<div class="youtube-video message_inline_image"><a data-id="nOJgD4fcZhI" href="http://www.youtube.com/watch_videos?video_ids=nOJgD4fcZhI,i96UO8-GFvw"><img src="https://i.ytimg.com/vi/nOJgD4fcZhI/default.jpg"></a></div>') self.assertEqual(converted, '<p><a href="http://www.youtube.com/watch_videos?video_ids=nOJgD4fcZhI,i96UO8-GFvw">http://www.youtube.com/watch_videos?video_ids=nOJgD4fcZhI,i96UO8-GFvw</a></p>\n<div class="youtube-video message_inline_image"><a data-id="nOJgD4fcZhI" href="http://www.youtube.com/watch_videos?video_ids=nOJgD4fcZhI,i96UO8-GFvw"><img src="https://i.ytimg.com/vi/nOJgD4fcZhI/default.jpg"></a></div>')
@override_settings(INLINE_URL_EMBED_PREVIEW=False) @override_settings(INLINE_URL_EMBED_PREVIEW=False)
def test_inline_vimeo(self) -> None: def test_inline_vimeo(self) -> None:
msg = 'Check out the debate: https://vimeo.com/246979354' msg = 'Check out the debate: https://vimeo.com/246979354'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>Check out the debate: <a href="https://vimeo.com/246979354">https://vimeo.com/246979354</a></p>') self.assertEqual(converted, '<p>Check out the debate: <a href="https://vimeo.com/246979354">https://vimeo.com/246979354</a></p>')
msg = 'https://vimeo.com/246979354' msg = 'https://vimeo.com/246979354'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p><a href="https://vimeo.com/246979354">https://vimeo.com/246979354</a></p>') self.assertEqual(converted, '<p><a href="https://vimeo.com/246979354">https://vimeo.com/246979354</a></p>')
@ -500,37 +500,37 @@ class BugdownTest(ZulipTestCase):
msg = msg.format(realm_id=realm.id) msg = msg.format(realm_id=realm.id)
thumbnail_img = '<img data-src-fullsize="/thumbnail?url=user_uploads%2F{realm_id}%2F50%2Fw2G6ok9kr8AMCQCTNAUOFMln%2FIMG_0677.JPG&amp;size=full" src="/thumbnail?url=user_uploads%2F{realm_id}%2F50%2Fw2G6ok9kr8AMCQCTNAUOFMln%2FIMG_0677.JPG&amp;size=thumbnail"><' thumbnail_img = '<img data-src-fullsize="/thumbnail?url=user_uploads%2F{realm_id}%2F50%2Fw2G6ok9kr8AMCQCTNAUOFMln%2FIMG_0677.JPG&amp;size=full" src="/thumbnail?url=user_uploads%2F{realm_id}%2F50%2Fw2G6ok9kr8AMCQCTNAUOFMln%2FIMG_0677.JPG&amp;size=thumbnail"><'
thumbnail_img = thumbnail_img.format(realm_id=realm.id) thumbnail_img = thumbnail_img.format(realm_id=realm.id)
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertIn(thumbnail_img, converted) self.assertIn(thumbnail_img, converted)
msg = 'https://www.google.com/images/srpr/logo4w.png' msg = 'https://www.google.com/images/srpr/logo4w.png'
thumbnail_img = '<img data-src-fullsize="/thumbnail?url=https%3A%2F%2Fwww.google.com%2Fimages%2Fsrpr%2Flogo4w.png&amp;size=full" src="/thumbnail?url=https%3A%2F%2Fwww.google.com%2Fimages%2Fsrpr%2Flogo4w.png&amp;size=thumbnail">' thumbnail_img = '<img data-src-fullsize="/thumbnail?url=https%3A%2F%2Fwww.google.com%2Fimages%2Fsrpr%2Flogo4w.png&amp;size=full" src="/thumbnail?url=https%3A%2F%2Fwww.google.com%2Fimages%2Fsrpr%2Flogo4w.png&amp;size=thumbnail">'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertIn(thumbnail_img, converted) self.assertIn(thumbnail_img, converted)
msg = 'www.google.com/images/srpr/logo4w.png' msg = 'www.google.com/images/srpr/logo4w.png'
thumbnail_img = '<img data-src-fullsize="/thumbnail?url=http%3A%2F%2Fwww.google.com%2Fimages%2Fsrpr%2Flogo4w.png&amp;size=full" src="/thumbnail?url=http%3A%2F%2Fwww.google.com%2Fimages%2Fsrpr%2Flogo4w.png&amp;size=thumbnail">' thumbnail_img = '<img data-src-fullsize="/thumbnail?url=http%3A%2F%2Fwww.google.com%2Fimages%2Fsrpr%2Flogo4w.png&amp;size=full" src="/thumbnail?url=http%3A%2F%2Fwww.google.com%2Fimages%2Fsrpr%2Flogo4w.png&amp;size=thumbnail">'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertIn(thumbnail_img, converted) self.assertIn(thumbnail_img, converted)
msg = 'https://www.google.com/images/srpr/logo4w.png' msg = 'https://www.google.com/images/srpr/logo4w.png'
thumbnail_img = '<div class="message_inline_image"><a href="https://www.google.com/images/srpr/logo4w.png"><img src="https://www.google.com/images/srpr/logo4w.png"></a></div>' thumbnail_img = '<div class="message_inline_image"><a href="https://www.google.com/images/srpr/logo4w.png"><img src="https://www.google.com/images/srpr/logo4w.png"></a></div>'
with self.settings(THUMBNAIL_IMAGES=False): with self.settings(THUMBNAIL_IMAGES=False):
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertIn(thumbnail_img, converted) self.assertIn(thumbnail_img, converted)
# Any url which is not an external link and doesn't start with # Any url which is not an external link and doesn't start with
# /user_uploads/ is not thumbnailed # /user_uploads/ is not thumbnailed
msg = '[foobar](/static/images/cute/turtle.png)' msg = '[foobar](/static/images/cute/turtle.png)'
thumbnail_img = '<div class="message_inline_image"><a href="/static/images/cute/turtle.png" title="foobar"><img src="/static/images/cute/turtle.png"></a></div>' thumbnail_img = '<div class="message_inline_image"><a href="/static/images/cute/turtle.png" title="foobar"><img src="/static/images/cute/turtle.png"></a></div>'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertIn(thumbnail_img, converted) self.assertIn(thumbnail_img, converted)
msg = '[foobar](/user_avatars/{realm_id}/emoji/images/50.png)' msg = '[foobar](/user_avatars/{realm_id}/emoji/images/50.png)'
msg = msg.format(realm_id=realm.id) msg = msg.format(realm_id=realm.id)
thumbnail_img = '<div class="message_inline_image"><a href="/user_avatars/{realm_id}/emoji/images/50.png" title="foobar"><img src="/user_avatars/{realm_id}/emoji/images/50.png"></a></div>' thumbnail_img = '<div class="message_inline_image"><a href="/user_avatars/{realm_id}/emoji/images/50.png" title="foobar"><img src="/user_avatars/{realm_id}/emoji/images/50.png"></a></div>'
thumbnail_img = thumbnail_img.format(realm_id=realm.id) thumbnail_img = thumbnail_img.format(realm_id=realm.id)
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertIn(thumbnail_img, converted) self.assertIn(thumbnail_img, converted)
@override_settings(INLINE_IMAGE_PREVIEW=True) @override_settings(INLINE_IMAGE_PREVIEW=True)
@ -676,14 +676,14 @@ class BugdownTest(ZulipTestCase):
msg = 'Look at how hilarious our old office was: https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG' msg = 'Look at how hilarious our old office was: https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG'
image_info = {'image': 'https://photos-4.dropbox.com/t/2/AABIre1oReJgPYuc_53iv0IHq1vUzRaDg2rrCfTpiWMccQ/12/129/jpeg/1024x1024/2/_/0/4/IMG_0923.JPG/CIEBIAEgAiAHKAIoBw/ymdijjcg67hv2ta/AABz2uuED1ox3vpWWvMpBxu6a/IMG_0923.JPG', 'desc': 'Shared with Dropbox', 'title': 'IMG_0923.JPG'} image_info = {'image': 'https://photos-4.dropbox.com/t/2/AABIre1oReJgPYuc_53iv0IHq1vUzRaDg2rrCfTpiWMccQ/12/129/jpeg/1024x1024/2/_/0/4/IMG_0923.JPG/CIEBIAEgAiAHKAIoBw/ymdijjcg67hv2ta/AABz2uuED1ox3vpWWvMpBxu6a/IMG_0923.JPG', 'desc': 'Shared with Dropbox', 'title': 'IMG_0923.JPG'}
with mock.patch('zerver.lib.markdown.fetch_open_graph_image', return_value=image_info): with mock.patch('zerver.lib.markdown.fetch_open_graph_image', return_value=image_info):
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>Look at how hilarious our old office was: <a href="https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG">https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG</a></p>\n<div class="message_inline_image"><a href="https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG" title="IMG_0923.JPG"><img src="https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG?dl=1"></a></div>') self.assertEqual(converted, '<p>Look at how hilarious our old office was: <a href="https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG">https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG</a></p>\n<div class="message_inline_image"><a href="https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG" title="IMG_0923.JPG"><img src="https://www.dropbox.com/s/ymdijjcg67hv2ta/IMG_0923.JPG?dl=1"></a></div>')
msg = 'Look at my hilarious drawing folder: https://www.dropbox.com/sh/cm39k9e04z7fhim/AAAII5NK-9daee3FcF41anEua?dl=' msg = 'Look at my hilarious drawing folder: https://www.dropbox.com/sh/cm39k9e04z7fhim/AAAII5NK-9daee3FcF41anEua?dl='
image_info = {'image': 'https://cf.dropboxstatic.com/static/images/icons128/folder_dropbox.png', 'desc': 'Shared with Dropbox', 'title': 'Saves'} image_info = {'image': 'https://cf.dropboxstatic.com/static/images/icons128/folder_dropbox.png', 'desc': 'Shared with Dropbox', 'title': 'Saves'}
with mock.patch('zerver.lib.markdown.fetch_open_graph_image', return_value=image_info): with mock.patch('zerver.lib.markdown.fetch_open_graph_image', return_value=image_info):
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>Look at my hilarious drawing folder: <a href="https://www.dropbox.com/sh/cm39k9e04z7fhim/AAAII5NK-9daee3FcF41anEua?dl=">https://www.dropbox.com/sh/cm39k9e04z7fhim/AAAII5NK-9daee3FcF41anEua?dl=</a></p>\n<div class="message_inline_ref"><a href="https://www.dropbox.com/sh/cm39k9e04z7fhim/AAAII5NK-9daee3FcF41anEua?dl=" title="Saves"><img src="https://cf.dropboxstatic.com/static/images/icons128/folder_dropbox.png"></a><div><div class="message_inline_image_title">Saves</div><desc class="message_inline_image_desc"></desc></div></div>') self.assertEqual(converted, '<p>Look at my hilarious drawing folder: <a href="https://www.dropbox.com/sh/cm39k9e04z7fhim/AAAII5NK-9daee3FcF41anEua?dl=">https://www.dropbox.com/sh/cm39k9e04z7fhim/AAAII5NK-9daee3FcF41anEua?dl=</a></p>\n<div class="message_inline_ref"><a href="https://www.dropbox.com/sh/cm39k9e04z7fhim/AAAII5NK-9daee3FcF41anEua?dl=" title="Saves"><img src="https://cf.dropboxstatic.com/static/images/icons128/folder_dropbox.png"></a><div><div class="message_inline_image_title">Saves</div><desc class="message_inline_image_desc"></desc></div></div>')
@ -692,7 +692,7 @@ class BugdownTest(ZulipTestCase):
msg = 'https://www.dropbox.com/sc/tditp9nitko60n5/03rEiZldy5' msg = 'https://www.dropbox.com/sc/tditp9nitko60n5/03rEiZldy5'
image_info = {'image': 'https://photos-6.dropbox.com/t/2/AAAlawaeD61TyNewO5vVi-DGf2ZeuayfyHFdNTNzpGq-QA/12/271544745/jpeg/1024x1024/2/_/0/5/baby-piglet.jpg/CKnjvYEBIAIgBygCKAc/tditp9nitko60n5/AADX03VAIrQlTl28CtujDcMla/0', 'desc': 'Shared with Dropbox', 'title': '1 photo'} image_info = {'image': 'https://photos-6.dropbox.com/t/2/AAAlawaeD61TyNewO5vVi-DGf2ZeuayfyHFdNTNzpGq-QA/12/271544745/jpeg/1024x1024/2/_/0/5/baby-piglet.jpg/CKnjvYEBIAIgBygCKAc/tditp9nitko60n5/AADX03VAIrQlTl28CtujDcMla/0', 'desc': 'Shared with Dropbox', 'title': '1 photo'}
with mock.patch('zerver.lib.markdown.fetch_open_graph_image', return_value=image_info): with mock.patch('zerver.lib.markdown.fetch_open_graph_image', return_value=image_info):
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p><a href="https://www.dropbox.com/sc/tditp9nitko60n5/03rEiZldy5">https://www.dropbox.com/sc/tditp9nitko60n5/03rEiZldy5</a></p>\n<div class="message_inline_image"><a href="https://www.dropbox.com/sc/tditp9nitko60n5/03rEiZldy5" title="1 photo"><img src="https://photos-6.dropbox.com/t/2/AAAlawaeD61TyNewO5vVi-DGf2ZeuayfyHFdNTNzpGq-QA/12/271544745/jpeg/1024x1024/2/_/0/5/baby-piglet.jpg/CKnjvYEBIAIgBygCKAc/tditp9nitko60n5/AADX03VAIrQlTl28CtujDcMla/0"></a></div>') self.assertEqual(converted, '<p><a href="https://www.dropbox.com/sc/tditp9nitko60n5/03rEiZldy5">https://www.dropbox.com/sc/tditp9nitko60n5/03rEiZldy5</a></p>\n<div class="message_inline_image"><a href="https://www.dropbox.com/sc/tditp9nitko60n5/03rEiZldy5" title="1 photo"><img src="https://photos-6.dropbox.com/t/2/AAAlawaeD61TyNewO5vVi-DGf2ZeuayfyHFdNTNzpGq-QA/12/271544745/jpeg/1024x1024/2/_/0/5/baby-piglet.jpg/CKnjvYEBIAIgBygCKAc/tditp9nitko60n5/AADX03VAIrQlTl28CtujDcMla/0"></a></div>')
@ -700,7 +700,7 @@ class BugdownTest(ZulipTestCase):
# Make sure we're not overzealous in our conversion: # Make sure we're not overzealous in our conversion:
msg = 'Look at the new dropbox logo: https://www.dropbox.com/static/images/home_logo.png' msg = 'Look at the new dropbox logo: https://www.dropbox.com/static/images/home_logo.png'
with mock.patch('zerver.lib.markdown.fetch_open_graph_image', return_value=None): with mock.patch('zerver.lib.markdown.fetch_open_graph_image', return_value=None):
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>Look at the new dropbox logo: <a href="https://www.dropbox.com/static/images/home_logo.png">https://www.dropbox.com/static/images/home_logo.png</a></p>\n<div class="message_inline_image"><a href="https://www.dropbox.com/static/images/home_logo.png"><img data-src-fullsize="/thumbnail?url=https%3A%2F%2Fwww.dropbox.com%2Fstatic%2Fimages%2Fhome_logo.png&amp;size=full" src="/thumbnail?url=https%3A%2F%2Fwww.dropbox.com%2Fstatic%2Fimages%2Fhome_logo.png&amp;size=thumbnail"></a></div>') self.assertEqual(converted, '<p>Look at the new dropbox logo: <a href="https://www.dropbox.com/static/images/home_logo.png">https://www.dropbox.com/static/images/home_logo.png</a></p>\n<div class="message_inline_image"><a href="https://www.dropbox.com/static/images/home_logo.png"><img data-src-fullsize="/thumbnail?url=https%3A%2F%2Fwww.dropbox.com%2Fstatic%2Fimages%2Fhome_logo.png&amp;size=full" src="/thumbnail?url=https%3A%2F%2Fwww.dropbox.com%2Fstatic%2Fimages%2Fhome_logo.png&amp;size=thumbnail"></a></div>')
@ -708,18 +708,18 @@ class BugdownTest(ZulipTestCase):
# Don't fail on bad dropbox links # Don't fail on bad dropbox links
msg = "https://zulip-test.dropbox.com/photos/cl/ROmr9K1XYtmpneM" msg = "https://zulip-test.dropbox.com/photos/cl/ROmr9K1XYtmpneM"
with mock.patch('zerver.lib.markdown.fetch_open_graph_image', return_value=None): with mock.patch('zerver.lib.markdown.fetch_open_graph_image', return_value=None):
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p><a href="https://zulip-test.dropbox.com/photos/cl/ROmr9K1XYtmpneM">https://zulip-test.dropbox.com/photos/cl/ROmr9K1XYtmpneM</a></p>') self.assertEqual(converted, '<p><a href="https://zulip-test.dropbox.com/photos/cl/ROmr9K1XYtmpneM">https://zulip-test.dropbox.com/photos/cl/ROmr9K1XYtmpneM</a></p>')
def test_inline_github_preview(self) -> None: def test_inline_github_preview(self) -> None:
# Test photo album previews # Test photo album previews
msg = 'Test: https://github.com/zulip/zulip/blob/master/static/images/logo/zulip-icon-128x128.png' msg = 'Test: https://github.com/zulip/zulip/blob/master/static/images/logo/zulip-icon-128x128.png'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>Test: <a href="https://github.com/zulip/zulip/blob/master/static/images/logo/zulip-icon-128x128.png">https://github.com/zulip/zulip/blob/master/static/images/logo/zulip-icon-128x128.png</a></p>\n<div class="message_inline_image"><a href="https://github.com/zulip/zulip/blob/master/static/images/logo/zulip-icon-128x128.png"><img data-src-fullsize="/thumbnail?url=https%3A%2F%2Fraw.githubusercontent.com%2Fzulip%2Fzulip%2Fmaster%2Fstatic%2Fimages%2Flogo%2Fzulip-icon-128x128.png&amp;size=full" src="/thumbnail?url=https%3A%2F%2Fraw.githubusercontent.com%2Fzulip%2Fzulip%2Fmaster%2Fstatic%2Fimages%2Flogo%2Fzulip-icon-128x128.png&amp;size=thumbnail"></a></div>') self.assertEqual(converted, '<p>Test: <a href="https://github.com/zulip/zulip/blob/master/static/images/logo/zulip-icon-128x128.png">https://github.com/zulip/zulip/blob/master/static/images/logo/zulip-icon-128x128.png</a></p>\n<div class="message_inline_image"><a href="https://github.com/zulip/zulip/blob/master/static/images/logo/zulip-icon-128x128.png"><img data-src-fullsize="/thumbnail?url=https%3A%2F%2Fraw.githubusercontent.com%2Fzulip%2Fzulip%2Fmaster%2Fstatic%2Fimages%2Flogo%2Fzulip-icon-128x128.png&amp;size=full" src="/thumbnail?url=https%3A%2F%2Fraw.githubusercontent.com%2Fzulip%2Fzulip%2Fmaster%2Fstatic%2Fimages%2Flogo%2Fzulip-icon-128x128.png&amp;size=thumbnail"></a></div>')
msg = 'Test: https://developer.github.com/assets/images/hero-circuit-bg.png' msg = 'Test: https://developer.github.com/assets/images/hero-circuit-bg.png'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>Test: <a href="https://developer.github.com/assets/images/hero-circuit-bg.png">https://developer.github.com/assets/images/hero-circuit-bg.png</a></p>\n<div class="message_inline_image"><a href="https://developer.github.com/assets/images/hero-circuit-bg.png"><img data-src-fullsize="/thumbnail?url=https%3A%2F%2Fdeveloper.github.com%2Fassets%2Fimages%2Fhero-circuit-bg.png&amp;size=full" src="/thumbnail?url=https%3A%2F%2Fdeveloper.github.com%2Fassets%2Fimages%2Fhero-circuit-bg.png&amp;size=thumbnail"></a></div>') self.assertEqual(converted, '<p>Test: <a href="https://developer.github.com/assets/images/hero-circuit-bg.png">https://developer.github.com/assets/images/hero-circuit-bg.png</a></p>\n<div class="message_inline_image"><a href="https://developer.github.com/assets/images/hero-circuit-bg.png"><img data-src-fullsize="/thumbnail?url=https%3A%2F%2Fdeveloper.github.com%2Fassets%2Fimages%2Fhero-circuit-bg.png&amp;size=full" src="/thumbnail?url=https%3A%2F%2Fdeveloper.github.com%2Fassets%2Fimages%2Fhero-circuit-bg.png&amp;size=thumbnail"></a></div>')
@ -770,41 +770,41 @@ class BugdownTest(ZulipTestCase):
'</div>') '</div>')
msg = 'http://www.twitter.com' msg = 'http://www.twitter.com'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>{}</p>'.format(make_link('http://www.twitter.com'))) self.assertEqual(converted, '<p>{}</p>'.format(make_link('http://www.twitter.com')))
msg = 'http://www.twitter.com/wdaher/' msg = 'http://www.twitter.com/wdaher/'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>{}</p>'.format(make_link('http://www.twitter.com/wdaher/'))) self.assertEqual(converted, '<p>{}</p>'.format(make_link('http://www.twitter.com/wdaher/')))
msg = 'http://www.twitter.com/wdaher/status/3' msg = 'http://www.twitter.com/wdaher/status/3'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>{}</p>'.format(make_link('http://www.twitter.com/wdaher/status/3'))) self.assertEqual(converted, '<p>{}</p>'.format(make_link('http://www.twitter.com/wdaher/status/3')))
# id too long # id too long
msg = 'http://www.twitter.com/wdaher/status/2879779692873154569' msg = 'http://www.twitter.com/wdaher/status/2879779692873154569'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>{}</p>'.format(make_link('http://www.twitter.com/wdaher/status/2879779692873154569'))) self.assertEqual(converted, '<p>{}</p>'.format(make_link('http://www.twitter.com/wdaher/status/2879779692873154569')))
# id too large (i.e. tweet doesn't exist) # id too large (i.e. tweet doesn't exist)
msg = 'http://www.twitter.com/wdaher/status/999999999999999999' msg = 'http://www.twitter.com/wdaher/status/999999999999999999'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>{}</p>'.format(make_link('http://www.twitter.com/wdaher/status/999999999999999999'))) self.assertEqual(converted, '<p>{}</p>'.format(make_link('http://www.twitter.com/wdaher/status/999999999999999999')))
msg = 'http://www.twitter.com/wdaher/status/287977969287315456' msg = 'http://www.twitter.com/wdaher/status/287977969287315456'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>{}</p>\n{}'.format( self.assertEqual(converted, '<p>{}</p>\n{}'.format(
make_link('http://www.twitter.com/wdaher/status/287977969287315456'), make_link('http://www.twitter.com/wdaher/status/287977969287315456'),
make_inline_twitter_preview('http://www.twitter.com/wdaher/status/287977969287315456', normal_tweet_html))) make_inline_twitter_preview('http://www.twitter.com/wdaher/status/287977969287315456', normal_tweet_html)))
msg = 'https://www.twitter.com/wdaher/status/287977969287315456' msg = 'https://www.twitter.com/wdaher/status/287977969287315456'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>{}</p>\n{}'.format( self.assertEqual(converted, '<p>{}</p>\n{}'.format(
make_link('https://www.twitter.com/wdaher/status/287977969287315456'), make_link('https://www.twitter.com/wdaher/status/287977969287315456'),
make_inline_twitter_preview('https://www.twitter.com/wdaher/status/287977969287315456', normal_tweet_html))) make_inline_twitter_preview('https://www.twitter.com/wdaher/status/287977969287315456', normal_tweet_html)))
msg = 'http://twitter.com/wdaher/status/287977969287315456' msg = 'http://twitter.com/wdaher/status/287977969287315456'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>{}</p>\n{}'.format( self.assertEqual(converted, '<p>{}</p>\n{}'.format(
make_link('http://twitter.com/wdaher/status/287977969287315456'), make_link('http://twitter.com/wdaher/status/287977969287315456'),
make_inline_twitter_preview('http://twitter.com/wdaher/status/287977969287315456', normal_tweet_html))) make_inline_twitter_preview('http://twitter.com/wdaher/status/287977969287315456', normal_tweet_html)))
@ -814,7 +814,7 @@ class BugdownTest(ZulipTestCase):
'http://twitter.com/wdaher/status/287977969287315457 ' 'http://twitter.com/wdaher/status/287977969287315457 '
'http://twitter.com/wdaher/status/287977969287315457 ' 'http://twitter.com/wdaher/status/287977969287315457 '
'http://twitter.com/wdaher/status/287977969287315457') 'http://twitter.com/wdaher/status/287977969287315457')
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>{} {} {} {}</p>\n{}{}'.format( self.assertEqual(converted, '<p>{} {} {} {}</p>\n{}{}'.format(
make_link('http://twitter.com/wdaher/status/287977969287315456'), make_link('http://twitter.com/wdaher/status/287977969287315456'),
make_link('http://twitter.com/wdaher/status/287977969287315457'), make_link('http://twitter.com/wdaher/status/287977969287315457'),
@ -828,7 +828,7 @@ class BugdownTest(ZulipTestCase):
'http://twitter.com/wdaher/status/287977969287315457 ' 'http://twitter.com/wdaher/status/287977969287315457 '
'https://twitter.com/wdaher/status/287977969287315456 ' 'https://twitter.com/wdaher/status/287977969287315456 '
'http://twitter.com/wdaher/status/287977969287315460') 'http://twitter.com/wdaher/status/287977969287315460')
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>{} {} {} {}</p>\n{}{}{}'.format( self.assertEqual(converted, '<p>{} {} {} {}</p>\n{}{}{}'.format(
make_link('http://twitter.com/wdaher/status/287977969287315456'), make_link('http://twitter.com/wdaher/status/287977969287315456'),
make_link('http://twitter.com/wdaher/status/287977969287315457'), make_link('http://twitter.com/wdaher/status/287977969287315457'),
@ -841,7 +841,7 @@ class BugdownTest(ZulipTestCase):
# Tweet has a mention in a URL, only the URL is linked # Tweet has a mention in a URL, only the URL is linked
msg = 'http://twitter.com/wdaher/status/287977969287315458' msg = 'http://twitter.com/wdaher/status/287977969287315458'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>{}</p>\n{}'.format( self.assertEqual(converted, '<p>{}</p>\n{}'.format(
make_link('http://twitter.com/wdaher/status/287977969287315458'), make_link('http://twitter.com/wdaher/status/287977969287315458'),
make_inline_twitter_preview('http://twitter.com/wdaher/status/287977969287315458', mention_in_link_tweet_html))) make_inline_twitter_preview('http://twitter.com/wdaher/status/287977969287315458', mention_in_link_tweet_html)))
@ -849,7 +849,7 @@ class BugdownTest(ZulipTestCase):
# Tweet with an image # Tweet with an image
msg = 'http://twitter.com/wdaher/status/287977969287315459' msg = 'http://twitter.com/wdaher/status/287977969287315459'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>{}</p>\n{}'.format( self.assertEqual(converted, '<p>{}</p>\n{}'.format(
make_link('http://twitter.com/wdaher/status/287977969287315459'), make_link('http://twitter.com/wdaher/status/287977969287315459'),
make_inline_twitter_preview('http://twitter.com/wdaher/status/287977969287315459', make_inline_twitter_preview('http://twitter.com/wdaher/status/287977969287315459',
@ -861,7 +861,7 @@ class BugdownTest(ZulipTestCase):
'</div>')))) '</div>'))))
msg = 'http://twitter.com/wdaher/status/287977969287315460' msg = 'http://twitter.com/wdaher/status/287977969287315460'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p>{}</p>\n{}'.format( self.assertEqual(converted, '<p>{}</p>\n{}'.format(
make_link('http://twitter.com/wdaher/status/287977969287315460'), make_link('http://twitter.com/wdaher/status/287977969287315460'),
make_inline_twitter_preview('http://twitter.com/wdaher/status/287977969287315460', emoji_in_tweet_html))) make_inline_twitter_preview('http://twitter.com/wdaher/status/287977969287315460', emoji_in_tweet_html)))
@ -911,11 +911,11 @@ class BugdownTest(ZulipTestCase):
def test_unicode_emoji(self) -> None: def test_unicode_emoji(self) -> None:
msg = '\u2615' # ☕ msg = '\u2615' # ☕
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p><span aria-label=\"coffee\" class="emoji emoji-2615" role=\"img\" title="coffee">:coffee:</span></p>') self.assertEqual(converted, '<p><span aria-label=\"coffee\" class="emoji emoji-2615" role=\"img\" title="coffee">:coffee:</span></p>')
msg = '\u2615\u2615' # ☕☕ msg = '\u2615\u2615' # ☕☕
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, '<p><span aria-label=\"coffee\" class="emoji emoji-2615" role=\"img\" title="coffee">:coffee:</span><span aria-label=\"coffee\" class="emoji emoji-2615" role=\"img\" title="coffee">:coffee:</span></p>') self.assertEqual(converted, '<p><span aria-label=\"coffee\" class="emoji emoji-2615" role=\"img\" title="coffee">:coffee:</span><span aria-label=\"coffee\" class="emoji emoji-2615" role=\"img\" title="coffee">:coffee:</span></p>')
def test_no_translate_emoticons_if_off(self) -> None: def test_no_translate_emoticons_if_off(self) -> None:
@ -930,10 +930,10 @@ class BugdownTest(ZulipTestCase):
def test_same_markup(self) -> None: def test_same_markup(self) -> None:
msg = '\u2615' # ☕ msg = '\u2615' # ☕
unicode_converted = bugdown_convert(msg) unicode_converted = markdown_convert(msg)
msg = ':coffee:' # ☕☕ msg = ':coffee:' # ☕☕
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual(converted, unicode_converted) self.assertEqual(converted, unicode_converted)
def test_links_in_topic_name(self) -> None: def test_links_in_topic_name(self) -> None:
@ -1336,33 +1336,33 @@ class BugdownTest(ZulipTestCase):
text = "```{}\nconsole.log('Hello World');\n```\n" text = "```{}\nconsole.log('Hello World');\n```\n"
# Render without default language # Render without default language
msg_with_js = bugdown_convert(text.format('js')) msg_with_js = markdown_convert(text.format('js'))
msg_with_python = bugdown_convert(text.format('python')) msg_with_python = markdown_convert(text.format('python'))
msg_without_language = bugdown_convert(text.format('')) msg_without_language = markdown_convert(text.format(''))
msg_with_quote = bugdown_convert(text.format('quote')) msg_with_quote = markdown_convert(text.format('quote'))
msg_with_math = bugdown_convert(text.format('math')) msg_with_math = markdown_convert(text.format('math'))
# Render with default=javascript # Render with default=javascript
do_set_realm_property(realm, 'default_code_block_language', 'javascript') do_set_realm_property(realm, 'default_code_block_language', 'javascript')
msg_without_language_default_js = bugdown_convert(text.format('')) msg_without_language_default_js = markdown_convert(text.format(''))
msg_with_python_default_js = bugdown_convert(text.format('python')) msg_with_python_default_js = markdown_convert(text.format('python'))
# Render with default=python # Render with default=python
do_set_realm_property(realm, 'default_code_block_language', 'python') do_set_realm_property(realm, 'default_code_block_language', 'python')
msg_without_language_default_py = bugdown_convert(text.format('')) msg_without_language_default_py = markdown_convert(text.format(''))
msg_with_none_default_py = bugdown_convert(text.format('none')) msg_with_none_default_py = markdown_convert(text.format('none'))
# Render with default=quote # Render with default=quote
do_set_realm_property(realm, 'default_code_block_language', 'quote') do_set_realm_property(realm, 'default_code_block_language', 'quote')
msg_without_language_default_quote = bugdown_convert(text.format('')) msg_without_language_default_quote = markdown_convert(text.format(''))
# Render with default=math # Render with default=math
do_set_realm_property(realm, 'default_code_block_language', 'math') do_set_realm_property(realm, 'default_code_block_language', 'math')
msg_without_language_default_math = bugdown_convert(text.format('')) msg_without_language_default_math = markdown_convert(text.format(''))
# Render without default language # Render without default language
do_set_realm_property(realm, 'default_code_block_language', None) do_set_realm_property(realm, 'default_code_block_language', None)
msg_without_language_final = bugdown_convert(text.format('')) msg_without_language_final = markdown_convert(text.format(''))
self.assertTrue(msg_with_js == msg_without_language_default_js) self.assertTrue(msg_with_js == msg_without_language_default_js)
self.assertTrue(msg_with_python == msg_with_python_default_js == msg_without_language_default_py) self.assertTrue(msg_with_python == msg_with_python_default_js == msg_without_language_default_py)
@ -1373,12 +1373,12 @@ class BugdownTest(ZulipTestCase):
# Test checking inside nested quotes # Test checking inside nested quotes
nested_text = "````quote\n\n{}\n\n{}````".format(text.format('js'), text.format('')) nested_text = "````quote\n\n{}\n\n{}````".format(text.format('js'), text.format(''))
do_set_realm_property(realm, 'default_code_block_language', 'javascript') do_set_realm_property(realm, 'default_code_block_language', 'javascript')
rendered = bugdown_convert(nested_text) rendered = markdown_convert(nested_text)
with_language, without_language = re.findall(r'<pre>(.*?)$', rendered, re.MULTILINE) with_language, without_language = re.findall(r'<pre>(.*?)$', rendered, re.MULTILINE)
self.assertTrue(with_language == without_language) self.assertTrue(with_language == without_language)
do_set_realm_property(realm, 'default_code_block_language', None) do_set_realm_property(realm, 'default_code_block_language', None)
rendered = bugdown_convert(nested_text) rendered = markdown_convert(nested_text)
with_language, without_language = re.findall(r'<pre>(.*?)$', rendered, re.MULTILINE) with_language, without_language = re.findall(r'<pre>(.*?)$', rendered, re.MULTILINE)
self.assertFalse(with_language == without_language) self.assertFalse(with_language == without_language)
@ -1920,7 +1920,7 @@ class BugdownTest(ZulipTestCase):
def test_image_preview_title(self) -> None: def test_image_preview_title(self) -> None:
msg = '[My favorite image](https://example.com/testimage.png)' msg = '[My favorite image](https://example.com/testimage.png)'
converted = bugdown_convert(msg) converted = markdown_convert(msg)
self.assertEqual( self.assertEqual(
converted, converted,
'<p>' '<p>'
@ -1971,7 +1971,7 @@ class BugdownTest(ZulipTestCase):
def test_disabled_code_block_processor(self) -> None: def test_disabled_code_block_processor(self) -> None:
msg = "Hello,\n\n" + \ msg = "Hello,\n\n" + \
" I am writing this message to test something. I am writing this message to test something." " I am writing this message to test something. I am writing this message to test something."
converted = bugdown_convert(msg) converted = markdown_convert(msg)
expected_output = '<p>Hello,</p>\n' + \ expected_output = '<p>Hello,</p>\n' + \
'<div class="codehilite"><pre><span></span><code>I am writing this message to test something. I am writing this message to test something.\n' + \ '<div class="codehilite"><pre><span></span><code>I am writing this message to test something. I am writing this message to test something.\n' + \
'</code></pre></div>' '</code></pre></div>'
@ -2076,7 +2076,7 @@ class BugdownTest(ZulipTestCase):
<div class="codehilite"><pre><span></span><code>&amp;copy; <div class="codehilite"><pre><span></span><code>&amp;copy;
</code></pre></div>""" </code></pre></div>"""
converted = bugdown_convert(dedent(msg)) converted = markdown_convert(dedent(msg))
self.assertEqual(converted, dedent(expected_output)) self.assertEqual(converted, dedent(expected_output))
class BugdownApiTests(ZulipTestCase): class BugdownApiTests(ZulipTestCase):
@ -2109,7 +2109,7 @@ class BugdownErrorTests(ZulipTestCase):
def test_bugdown_error_handling(self) -> None: def test_bugdown_error_handling(self) -> None:
with self.simulated_markdown_failure(): with self.simulated_markdown_failure():
with self.assertRaises(MarkdownRenderingException): with self.assertRaises(MarkdownRenderingException):
bugdown_convert('') markdown_convert('')
def test_send_message_errors(self) -> None: def test_send_message_errors(self) -> None:
@ -2128,7 +2128,7 @@ class BugdownErrorTests(ZulipTestCase):
with mock.patch('zerver.lib.markdown.timeout', return_value=msg), \ with mock.patch('zerver.lib.markdown.timeout', return_value=msg), \
mock.patch('zerver.lib.markdown.markdown_logger'): mock.patch('zerver.lib.markdown.markdown_logger'):
with self.assertRaises(MarkdownRenderingException): with self.assertRaises(MarkdownRenderingException):
bugdown_convert(msg) markdown_convert(msg)
def test_curl_code_block_validation(self) -> None: def test_curl_code_block_validation(self) -> None:
processor = FencedBlockPreprocessor(None) processor = FencedBlockPreprocessor(None)