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.

test_migrations: Look users up through the historical models.

Aman Agrawal33f6a84f177a
diff --git a/zerver/tests/test_migrations.py b/zerver/tests/test_migrations.py
index 9ca36df13e1..8930ae85987 100644
--- a/zerver/tests/test_migrations.py
+++ b/zerver/tests/test_migrations.py
@@ -28,11 +28,13 @@ class FixDeletedUserEmail(MigrationsTestCase):
@override
def setUpBeforeMigration(self, apps: StateApps) -> None:
+ Realm = apps.get_model("zerver", "Realm")
UserProfile = apps.get_model("zerver", "UserProfile")
+ realm = Realm.objects.get(string_id="zulip")
# Simulate a user deleted before the fix in 208c0c303405,
# after 0439_fix_deleteduser_email repaired delivery_email.
- deleted_user = self.example_user("hamlet")
+ deleted_user = UserProfile.objects.get(realm=realm, delivery_email="[email protected]")
UserProfile.objects.filter(id=deleted_user.id).update(
is_active=False,
email=f"deleteduser{deleted_user.id}@https://zulip.testserver",
@@ -41,13 +43,13 @@ class FixDeletedUserEmail(MigrationsTestCase):
self.deleted_user_id = deleted_user.id
# A normal active user, as a control.
- control_user = self.example_user("cordelia")
+ control_user = UserProfile.objects.get(realm=realm, delivery_email="[email protected]")
self.control_user_id = control_user.id
self.control_user_email = control_user.email
# A deactivated user with a valid email, as a control for the
# is_active=False part of the migration's filter.
- deactivated_user = self.example_user("othello")
+ deactivated_user = UserProfile.objects.get(realm=realm, delivery_email="[email protected]")
UserProfile.objects.filter(id=deactivated_user.id).update(is_active=False)
self.deactivated_user_id = deactivated_user.id
self.deactivated_user_email = deactivated_user.email