Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

tests: Verify warning log if multiple teams found in mattermost import.

Mohit Gupta9a10929a6cec
diff --git a/zerver/tests/test_mattermost_importer.py b/zerver/tests/test_mattermost_importer.py
index 725b18ecc8e..e90821b03fc 100644
--- a/zerver/tests/test_mattermost_importer.py
+++ b/zerver/tests/test_mattermost_importer.py
@@ -503,7 +503,7 @@ class MatterMostImporter(ZulipTestCase):
mattermost_data_dir = self.fixture_file_name("", "mattermost_fixtures")
output_dir = self.make_import_output_dir("mattermost")
- with patch('builtins.print') as mock_print:
+ with patch('builtins.print') as mock_print, self.assertLogs(level='WARNING') as warn_log:
do_convert_data(
mattermost_data_dir=mattermost_data_dir,
output_dir=output_dir,
@@ -513,6 +513,10 @@ class MatterMostImporter(ZulipTestCase):
call('Generating data for', 'gryffindor'),
call('Generating data for', 'slytherin')
])
+ self.assertEqual(warn_log.output, [
+ 'WARNING:root:Skipping importing huddles and PMs since there are multiple teams in the export',
+ 'WARNING:root:Skipping importing huddles and PMs since there are multiple teams in the export',
+ ])
harry_team_output_dir = self.team_output_dir(output_dir, "gryffindor")
self.assertEqual(os.path.exists(os.path.join(harry_team_output_dir, 'avatars')), True)
@@ -676,7 +680,7 @@ class MatterMostImporter(ZulipTestCase):
mattermost_data_dir = self.fixture_file_name("", "mattermost_fixtures")
output_dir = self.make_import_output_dir("mattermost")
- with patch('builtins.print') as mock_print:
+ with patch('builtins.print') as mock_print, self.assertLogs(level='WARNING') as warn_log:
do_convert_data(
mattermost_data_dir=mattermost_data_dir,
output_dir=output_dir,
@@ -686,6 +690,10 @@ class MatterMostImporter(ZulipTestCase):
call('Generating data for', 'gryffindor'),
call('Generating data for', 'slytherin')
])
+ self.assertEqual(warn_log.output, [
+ 'WARNING:root:Skipping importing huddles and PMs since there are multiple teams in the export',
+ 'WARNING:root:Skipping importing huddles and PMs since there are multiple teams in the export',
+ ])
harry_team_output_dir = self.team_output_dir(output_dir, "gryffindor")
messages = self.read_file(harry_team_output_dir, 'messages-000001.json')
@@ -696,7 +704,7 @@ class MatterMostImporter(ZulipTestCase):
mattermost_data_dir = self.fixture_file_name("", "mattermost_fixtures")
output_dir = self.make_import_output_dir("mattermost")
- with patch('builtins.print') as mock_print:
+ with patch('builtins.print') as mock_print, self.assertLogs(level='WARNING') as warn_log:
do_convert_data(
mattermost_data_dir=mattermost_data_dir,
output_dir=output_dir,
@@ -706,6 +714,10 @@ class MatterMostImporter(ZulipTestCase):
call('Generating data for', 'gryffindor'),
call('Generating data for', 'slytherin')
])
+ self.assertEqual(warn_log.output, [
+ 'WARNING:root:Skipping importing huddles and PMs since there are multiple teams in the export',
+ 'WARNING:root:Skipping importing huddles and PMs since there are multiple teams in the export',
+ ])
harry_team_output_dir = self.team_output_dir(output_dir, "gryffindor")