From a7439919358f19b2667190e4b0e702fc61abdde5 Mon Sep 17 00:00:00 2001 From: Vishnu KS Date: Sat, 31 Aug 2019 14:32:59 +0200 Subject: [PATCH] mattermost: Fix mirror dummy fixture data. The channel where Snape sends message should be gryffindor-quidditch-team and not slytherin-quidditch-team since he is mirror dummy in gryffindor. --- zerver/tests/fixtures/mattermost_fixtures/export.json | 2 +- zerver/tests/test_mattermost_importer.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/zerver/tests/fixtures/mattermost_fixtures/export.json b/zerver/tests/fixtures/mattermost_fixtures/export.json index 70d3f800b3..d912d6b324 100644 --- a/zerver/tests/fixtures/mattermost_fixtures/export.json +++ b/zerver/tests/fixtures/mattermost_fixtures/export.json @@ -30,6 +30,6 @@ {"type":"post","post":{"team":"slytherin","channel":"slytherin-quidditch-team","user":"malfoy","message":":rofl: 4","create_at":1553166916448,"reactions":[{"user":"harry","create_at":1553167016056,"emoji_name":"peerdium"}],"replies":null}} {"type":"post","post":{"team":"slytherin","channel":"slytherin-quidditch-team","user":"malfoy","message":"Hello folks","create_at":1553166858280,"reactions":[{"user":"harry","create_at":1553166903980,"emoji_name":"joy"}],"replies":null}} {"type":"post","post":{"team":"gryffindor","channel":"gryffindor-common-room","user":"harry","message":"harry joined the channel.","create_at":1553165141689,"reactions":null,"replies":null}} -{"type":"post","post":{"team":"gryffindor","channel":"slytherin-quidditch-team","user":"snape","message":"Hey folks! I was always in your team. Time to go now.","create_at":1553166740759,"reactions":null,"replies":null}} +{"type":"post","post":{"team":"gryffindor","channel":"gryffindor-quidditch-team","user":"snape","message":"Hey folks! I was always in your team. Time to go now.","create_at":1553166740759,"reactions":null,"replies":null}} {"type":"emoji","emoji":{"name":"peerdium","image":"exported_emoji/h15ni7kf1bnj7jeua4qhmctsdo/image.png"}} {"type":"emoji","emoji":{"name":"tick","image":"exported_emoji/7u7x8ytgp78q8jir81o9ejwwnr/image.png"}} diff --git a/zerver/tests/test_mattermost_importer.py b/zerver/tests/test_mattermost_importer.py index eefe963b09..74f3ee48cb 100644 --- a/zerver/tests/test_mattermost_importer.py +++ b/zerver/tests/test_mattermost_importer.py @@ -19,7 +19,7 @@ from zerver.data_import.mattermost import mattermost_data_file_to_dict, process_ build_reactions, get_name_to_codepoint_dict, do_convert_data from zerver.data_import.sequencer import IdMapper from zerver.data_import.import_util import SubscriberHandler -from zerver.models import Reaction, UserProfile, Message, get_realm +from zerver.models import Reaction, UserProfile, Message, get_realm, get_user class MatterMostImporter(ZulipTestCase): logger = logging.getLogger() @@ -471,7 +471,7 @@ class MatterMostImporter(ZulipTestCase): self.assertIn(messages['zerver_message'][0]['content'], 'harry joined the channel.\n\n') exported_usermessage_userprofiles = self.get_set(messages['zerver_usermessage'], 'user_profile') - self.assertEqual(len(exported_usermessage_userprofiles), 2) + self.assertEqual(len(exported_usermessage_userprofiles), 3) exported_usermessage_messages = self.get_set(messages['zerver_usermessage'], 'message') self.assertEqual(exported_usermessage_messages, exported_messages_id) @@ -481,8 +481,11 @@ class MatterMostImporter(ZulipTestCase): ) realm = get_realm('gryffindor') - realm_users = UserProfile.objects.filter(realm=realm) - messages = Message.objects.filter(sender__in=realm_users) + self.assertFalse(get_user("harry@zulip.com", realm).is_mirror_dummy) + self.assertFalse(get_user("ron@zulip.com", realm).is_mirror_dummy) + self.assertTrue(get_user("snape@zulip.com", realm).is_mirror_dummy) + + messages = Message.objects.filter(sender__realm=realm) for message in messages: self.assertIsNotNone(message.rendered_content)