From 318c55e0302c10cda3d33003ebfac09d3a0ce94e Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Thu, 16 Jul 2020 13:38:56 +0000 Subject: [PATCH] export: Export AlertWord table. --- zerver/lib/export.py | 8 ++++++++ zerver/tests/test_import_export.py | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/zerver/lib/export.py b/zerver/lib/export.py index cf46fced3f..f237abdc53 100644 --- a/zerver/lib/export.py +++ b/zerver/lib/export.py @@ -30,6 +30,7 @@ from scripts.lib.zulip_tools import overwrite_symlink from zerver.lib.avatar_hash import user_avatar_path_from_ids from zerver.lib.pysa import mark_sanitized from zerver.models import ( + AlertWord, Attachment, BotConfigData, BotStorageData, @@ -621,6 +622,13 @@ def get_realm_config() -> Config: custom_fetch=fetch_user_profile, ) + Config( + table='zerver_alertword', + model=AlertWord, + normal_parent=user_profile_config, + parent_key='user_profile__in', + ) + user_groups_config = Config( table='zerver_usergroup', model=UserGroup, diff --git a/zerver/tests/test_import_export.py b/zerver/tests/test_import_export.py index 549c48b8f2..459582009b 100644 --- a/zerver/tests/test_import_export.py +++ b/zerver/tests/test_import_export.py @@ -447,6 +447,18 @@ class ImportExportTest(ZulipTestCase): {'Denmark', 'Rome', 'Scotland', 'Venice', 'Verona'}, ) + exported_alert_words = data['zerver_alertword'] + + # We set up 4 alert words for Hamlet, Cordelia, etc. + # when we populate the test database. + num_zulip_users = 9 + self.assertEqual(len(exported_alert_words), num_zulip_users * 4) + + self.assertIn( + 'robotics', + {r['word'] for r in exported_alert_words} + ) + data = full_data['message'] um = UserMessage.objects.all()[0] exported_um = self.find_by_id(data['zerver_usermessage'], um.id)