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.

export: Export AlertWord table.

Steve Howell318c55e0302c
diff --git a/zerver/lib/export.py b/zerver/lib/export.py
index cf46fced3f0..f237abdc538 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 549c48b8f27..459582009b8 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)