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.

migrations: Don't push events to deferred_work queue if TEST_SUITE.

Mateusz Mandera26f9f3cc4b3d
diff --git a/zerver/migrations/0376_set_realmemoji_author_and_reupload_realmemoji.py b/zerver/migrations/0376_set_realmemoji_author_and_reupload_realmemoji.py
index 675c2b2506c..e0cc61f3fc3 100644
--- a/zerver/migrations/0376_set_realmemoji_author_and_reupload_realmemoji.py
+++ b/zerver/migrations/0376_set_realmemoji_author_and_reupload_realmemoji.py
@@ -1,3 +1,4 @@
+from django.conf import settings
from django.db import migrations
from django.db.backends.postgresql.schema import DatabaseSchemaEditor
from django.db.migrations.state import StateApps
@@ -10,6 +11,7 @@ def set_emoji_author(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> No
This migration establishes the invariant that all RealmEmoji objects have .author set
and queues events for reuploading all RealmEmoji.
"""
+
RealmEmoji = apps.get_model("zerver", "RealmEmoji")
Realm = apps.get_model("zerver", "Realm")
UserProfile = apps.get_model("zerver", "UserProfile")
@@ -30,6 +32,12 @@ def set_emoji_author(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> No
RealmEmoji.objects.bulk_update(realm_emoji_to_update, ["author_id"])
+ if settings.TEST_SUITE:
+ # There are no custom emoji in the test suite data set, and
+ # the below code won't work because RabbitMQ isn't enabled for
+ # the test suite.
+ return
+
for realm_id in Realm.objects.order_by("id").values_list("id", flat=True):
event = {
"type": "reupload_realm_emoji",