populate_db: Add alert words for Zulip users.

This commit is contained in:
Steve Howell
2020-07-09 13:48:10 +00:00
committed by Tim Abbott
parent 63b15b77a3
commit 7c0fa3aefc
3 changed files with 68 additions and 12 deletions

View File

@@ -4,7 +4,7 @@ from zerver.lib.actions import do_add_alert_words, do_remove_alert_words
from zerver.lib.alert_words import alert_words_in_realm, user_alert_words
from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.test_helpers import most_recent_message, most_recent_usermessage
from zerver.models import UserProfile
from zerver.models import AlertWord, UserProfile
class AlertWordTests(ZulipTestCase):
@@ -13,7 +13,11 @@ class AlertWordTests(ZulipTestCase):
def get_user(self) -> UserProfile:
# One nice thing about Hamlet is that he is
# already subscribed to Denmark.
return self.example_user('hamlet')
user = self.example_user('hamlet')
# delete words from populate_db to simplify tests
AlertWord.objects.filter(user_profile=user).delete()
return user
def test_internal_endpoint(self) -> None:
user = self.get_user()
@@ -91,6 +95,10 @@ class AlertWordTests(ZulipTestCase):
alert_words_in_realm. Alerts added for one user do not impact other
users.
"""
# Clear all the words that we got from populate_db.
AlertWord.objects.all().delete()
user1 = self.get_user()
do_add_alert_words(user1, self.interesting_alert_word_list)