mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
slack importer: Add test for checking link in message conversion.
This commit is contained in:
@@ -92,9 +92,14 @@ def convert_to_zulip_markdown(text: str, users: List[ZerverFieldsT],
|
||||
# Check and convert link format
|
||||
text, has_link = convert_link_format(text)
|
||||
# convert `<mailto:foo@foo.com>` to `mailto:foo@foo.com`
|
||||
text, has_link = convert_mailto_format(text)
|
||||
text, has_mailto_link = convert_mailto_format(text)
|
||||
|
||||
return text, mentioned_users_id, has_link
|
||||
if has_link is True or has_mailto_link is True:
|
||||
message_has_link = True
|
||||
else:
|
||||
message_has_link = False
|
||||
|
||||
return text, mentioned_users_id, message_has_link
|
||||
|
||||
def get_user_mentions(token: str, users: List[ZerverFieldsT],
|
||||
added_users: AddedUsersT) -> Tuple[str, int]:
|
||||
|
||||
@@ -86,3 +86,20 @@ class SlackMessageConversion(ZulipTestCase):
|
||||
text, mentioned_users, has_link = convert_to_zulip_markdown(message, users, slack_user_map)
|
||||
self.assertEqual(text, message)
|
||||
self.assertEqual(mentioned_users, [])
|
||||
|
||||
def test_has_link(self) -> None:
|
||||
slack_user_map = {} # type: Dict[str, int]
|
||||
|
||||
message = '<http://journals.plos.org/plosone/article>'
|
||||
text, mentioned_users, has_link = convert_to_zulip_markdown(message, [], slack_user_map)
|
||||
self.assertEqual(text, 'http://journals.plos.org/plosone/article')
|
||||
self.assertEqual(has_link, True)
|
||||
|
||||
message = '<mailto:foo@foo.com>'
|
||||
text, mentioned_users, has_link = convert_to_zulip_markdown(message, [], slack_user_map)
|
||||
self.assertEqual(text, 'mailto:foo@foo.com')
|
||||
self.assertEqual(has_link, True)
|
||||
|
||||
message = 'random message'
|
||||
text, mentioned_users, has_link = convert_to_zulip_markdown(message, [], slack_user_map)
|
||||
self.assertEqual(has_link, False)
|
||||
|
||||
Reference in New Issue
Block a user