export: Export AlertWord table.

This commit is contained in:
Steve Howell
2020-07-16 13:38:56 +00:00
committed by Tim Abbott
parent 23e0ea5e32
commit 318c55e030
2 changed files with 20 additions and 0 deletions

View File

@@ -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.avatar_hash import user_avatar_path_from_ids
from zerver.lib.pysa import mark_sanitized from zerver.lib.pysa import mark_sanitized
from zerver.models import ( from zerver.models import (
AlertWord,
Attachment, Attachment,
BotConfigData, BotConfigData,
BotStorageData, BotStorageData,
@@ -621,6 +622,13 @@ def get_realm_config() -> Config:
custom_fetch=fetch_user_profile, 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( user_groups_config = Config(
table='zerver_usergroup', table='zerver_usergroup',
model=UserGroup, model=UserGroup,

View File

@@ -447,6 +447,18 @@ class ImportExportTest(ZulipTestCase):
{'Denmark', 'Rome', 'Scotland', 'Venice', 'Verona'}, {'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'] data = full_data['message']
um = UserMessage.objects.all()[0] um = UserMessage.objects.all()[0]
exported_um = self.find_by_id(data['zerver_usermessage'], um.id) exported_um = self.find_by_id(data['zerver_usermessage'], um.id)