Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
slack_importer: Add test cases for colliding thread topics.
PieterCK9806c74cb00b
diff --git a/zerver/tests/fixtures/slack_fixtures/exported_messages_fixtures/thread_with_long_topic_name.json b/zerver/tests/fixtures/slack_fixtures/exported_messages_fixtures/thread_with_long_topic_name.jsonindex 703606356cb..2aaeb6e17a9 100644--- a/zerver/tests/fixtures/slack_fixtures/exported_messages_fixtures/thread_with_long_topic_name.json+++ b/zerver/tests/fixtures/slack_fixtures/exported_messages_fixtures/thread_with_long_topic_name.json@@ -13,5 +13,20 @@"parent_user_id": "U061A5N1G","thread_ts": "1439868294.000008","channel_name": "random"+ },+ {+ "text": "random message but it is too long for the thread two electric boogaloo",+ "user": "U061A1R2R",+ "ts": "1439868294.000008",+ "thread_ts": "1439868294.000008",+ "channel_name": "random"+ },+ {+ "text": "second thread",+ "user": "U061A5N1G",+ "ts": "1439869294.000008",+ "parent_user_id": "U061A1R2R",+ "thread_ts": "1439868294.000008",+ "channel_name": "random"}]diff --git a/zerver/tests/fixtures/slack_fixtures/exported_messages_fixtures/threads_with_colliding_topic_names.json b/zerver/tests/fixtures/slack_fixtures/exported_messages_fixtures/threads_with_colliding_topic_names.jsonindex 2c8202a2a2d..02c4b552645 100644--- a/zerver/tests/fixtures/slack_fixtures/exported_messages_fixtures/threads_with_colliding_topic_names.json+++ b/zerver/tests/fixtures/slack_fixtures/exported_messages_fixtures/threads_with_colliding_topic_names.json@@ -28,5 +28,20 @@"parent_user_id": "U061A5N1G","thread_ts": "1434139200.000002","channel_name": "random"+ },+ {+ "text": "message body text",+ "user": "U061A5N1G",+ "ts": "144139100.000008",+ "thread_ts": "144139100.000008",+ "channel_name": "random"+ },+ {+ "text": "This thread shouldn't collide",+ "user": "U061A1R2R",+ "ts": "1439869295.000008",+ "parent_user_id": "U061A5N1G",+ "thread_ts": "144139100.000008",+ "channel_name": "random"}]diff --git a/zerver/tests/test_slack_importer.py b/zerver/tests/test_slack_importer.pyindex b1b73c8adb7..4678868ab0c 100644--- a/zerver/tests/test_slack_importer.py+++ b/zerver/tests/test_slack_importer.py@@ -1499,17 +1499,34 @@ class SlackImporter(ZulipTestCase):) = self.run_channel_message_to_zerver_message_with_fixtures(["thread_with_long_topic_name"])- self.assert_length(zerver_message, 2)+ self.assert_length(zerver_message, 4)# Test thread topic name cut off.- expected_thread_message_1_content = (+ expected_thread_1_message_1_content = ("random message but it is too long for the thread topic name")- expected_thread_topic_name = "2015-08-18 random message but it is too long for the thread…"- self.assertEqual(zerver_message[0]["content"], expected_thread_message_1_content)- self.assertEqual(zerver_message[0][EXPORT_TOPIC_NAME], expected_thread_topic_name)+ expected_thread_1_topic_name = (+ "2015-08-18 random message but it is too long for the thread…"+ )+ self.assertEqual(zerver_message[0]["content"], expected_thread_1_message_1_content)+ self.assertEqual(zerver_message[0][EXPORT_TOPIC_NAME], expected_thread_1_topic_name)# Record that truncation should use the full maximum topic length.self.assert_length(zerver_message[0][EXPORT_TOPIC_NAME], 60)+ ### THREAD 2 CONVERSATION ###+ # Test that two different thread topics, despite having unique+ # original topic names, will collide if their truncated names+ # are identical.+ expected_thread_2_message_1_content = (+ "random message but it is too long for the thread two electric boogaloo"+ )+ expected_thread_2_topic_name = (+ "2015-08-18 random message but it is too long for the th… (2)"+ )+ self.assertEqual(zerver_message[2]["content"], expected_thread_2_message_1_content)+ self.assertEqual(zerver_message[2][EXPORT_TOPIC_NAME], expected_thread_2_topic_name)+ # Record that truncation should use the full maximum topic length.+ self.assert_length(zerver_message[2][EXPORT_TOPIC_NAME], 60)+def test_convert_colliding_thread_topic_names(self) -> None:(zerver_message,@@ -1520,7 +1537,7 @@ class SlackImporter(ZulipTestCase):) = self.run_channel_message_to_zerver_message_with_fixtures(["threads_with_colliding_topic_names"])- self.assert_length(zerver_message, 4)+ self.assert_length(zerver_message, 6)### THREAD 1 CONVERSATION ###expected_thread_1_message_1_content = "message body text"expected_thread_1_topic_name = "2015-06-12 message body text"@@ -1534,6 +1551,12 @@ class SlackImporter(ZulipTestCase):self.assertEqual(zerver_message[2]["content"], expected_thread_2_message_1_content)self.assertEqual(zerver_message[2][EXPORT_TOPIC_NAME], expected_thread_2_topic_name)+ ### THREAD 3 CONVERSATION ###+ # Test two thread topic names with the same message+ # snippet don't collide if they're on different days.+ expected_thread_3_topic_name = "1974-07-27 message body text"+ self.assertEqual(zerver_message[4][EXPORT_TOPIC_NAME], expected_thread_3_topic_name)+def test_convert_thread_topic_name_with_mention_syntax(self) -> None:(zerver_message,