diff --git a/zerver/tests/test_bugdown.py b/zerver/tests/test_bugdown.py index add925debf..4fad31bd3b 100644 --- a/zerver/tests/test_bugdown.py +++ b/zerver/tests/test_bugdown.py @@ -388,10 +388,12 @@ class BugdownTest(ZulipTestCase): self.assertEqual(converted, '

https://vimeo.com/246979354

') @override_settings(INLINE_IMAGE_PREVIEW=True) - def test_inline_image_thumbnail_url(self): - # type: () -> None - msg = '[foobar](/user_uploads/2/50/w2G6ok9kr8AMCQCTNAUOFMln/IMG_0677.JPG)' - thumbnail_img = '<' + def test_inline_image_thumbnail_url(self) -> None: + realm = get_realm("zephyr") + msg = '[foobar](/user_uploads/{realm_id}/50/w2G6ok9kr8AMCQCTNAUOFMln/IMG_0677.JPG)' + msg = msg.format(realm_id=realm.id) + thumbnail_img = '<' + thumbnail_img = thumbnail_img.format(realm_id=realm.id) converted = bugdown_convert(msg) self.assertIn(thumbnail_img, converted) @@ -418,14 +420,15 @@ class BugdownTest(ZulipTestCase): converted = bugdown_convert(msg) self.assertIn(thumbnail_img, converted) - msg = '[foobar](/user_avatars/2/emoji/images/50.png)' - thumbnail_img = '
' + msg = '[foobar](/user_avatars/{realm_id}/emoji/images/50.png)' + msg = msg.format(realm_id=realm.id) + thumbnail_img = '
' + thumbnail_img = thumbnail_img.format(realm_id=realm.id) converted = bugdown_convert(msg) self.assertIn(thumbnail_img, converted) @override_settings(INLINE_IMAGE_PREVIEW=True) - def test_inline_image_preview(self): - # type: () -> None + def test_inline_image_preview(self) -> None: with_preview = '
' without_preview = '

http://cdn.wallpapersafari.com/13/6/16eVjx.jpeg

' content = 'http://cdn.wallpapersafari.com/13/6/16eVjx.jpeg' @@ -469,6 +472,7 @@ class BugdownTest(ZulipTestCase): @override_settings(INLINE_IMAGE_PREVIEW=True) def test_inline_image_preview_order(self) -> None: + realm = get_realm("zulip") content = 'http://imaging.nikon.com/lineup/dslr/df/img/sample/img_01.jpg\nhttp://imaging.nikon.com/lineup/dslr/df/img/sample/img_02.jpg\nhttp://imaging.nikon.com/lineup/dslr/df/img/sample/img_03.jpg' expected = '

http://imaging.nikon.com/lineup/dslr/df/img/sample/img_01.jpg
\nhttp://imaging.nikon.com/lineup/dslr/df/img/sample/img_02.jpg
\nhttp://imaging.nikon.com/lineup/dslr/df/img/sample/img_03.jpg

\n
' @@ -485,8 +489,10 @@ class BugdownTest(ZulipTestCase): converted = render_markdown(msg, content) self.assertEqual(converted, expected) - content = 'Test 1\n[21136101110_1dde1c1a7e_o.jpg](/user_uploads/1/6d/F1PX6u16JA2P-nK45PyxHIYZ/21136101110_1dde1c1a7e_o.jpg) \n\nNext Image\n[IMG_20161116_023910.jpg](/user_uploads/1/69/sh7L06e7uH7NaX6d5WFfVYQp/IMG_20161116_023910.jpg) \n\nAnother Screenshot\n[Screenshot-from-2016-06-01-16-22-42.png](/user_uploads/1/70/_aZmIEWaN1iUaxwkDjkO7bpj/Screenshot-from-2016-06-01-16-22-42.png)' - expected = '

Test 1
\n21136101110_1dde1c1a7e_o.jpg

\n

Next Image
\nIMG_20161116_023910.jpg

\n

Another Screenshot
\nScreenshot-from-2016-06-01-16-22-42.png

\n
' + content = 'Test 1\n[21136101110_1dde1c1a7e_o.jpg](/user_uploads/{realm_id}/6d/F1PX6u16JA2P-nK45PyxHIYZ/21136101110_1dde1c1a7e_o.jpg) \n\nNext Image\n[IMG_20161116_023910.jpg](/user_uploads/{realm_id}/69/sh7L06e7uH7NaX6d5WFfVYQp/IMG_20161116_023910.jpg) \n\nAnother Screenshot\n[Screenshot-from-2016-06-01-16-22-42.png](/user_uploads/{realm_id}/70/_aZmIEWaN1iUaxwkDjkO7bpj/Screenshot-from-2016-06-01-16-22-42.png)' + content = content.format(realm_id=realm.id) + expected = '

Test 1
\n21136101110_1dde1c1a7e_o.jpg

\n

Next Image
\nIMG_20161116_023910.jpg

\n

Another Screenshot
\nScreenshot-from-2016-06-01-16-22-42.png

\n
' + expected = expected.format(realm_id=realm.id) msg = Message(sender=sender_user_profile, sending_client=get_client("test")) converted = render_markdown(msg, content)