Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
tests: Don't assume the test database was built recently.
Anders Kaseorgbd9482a02493
diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.pyindex b91f5c284fb..2221efebc40 100644--- a/zerver/tests/test_events.py+++ b/zerver/tests/test_events.py@@ -4201,6 +4201,10 @@ class NormalActionsTest(BaseAction):self.subscribe(hamlet, "test_stream1")stream = get_stream("test_stream1", self.user_profile.realm)+ # Make all other streams recently active, regardless of when+ # the test database was built.+ Message.objects.update(date_sent=timezone_now())+# Delete all messages in the stream so that it becomes inactive.Message.objects.filter(recipient__type_id=stream.id, realm=stream.realm).delete()diff --git a/zerver/tests/test_reminders.py b/zerver/tests/test_reminders.pyindex 3bda9998190..16b9824aa90 100644--- a/zerver/tests/test_reminders.py+++ b/zerver/tests/test_reminders.py@@ -5,6 +5,7 @@ from typing import TYPE_CHECKINGfrom unittest import mockimport time_machine+from typing_extensions import overridefrom zerver.actions.realm_settings import do_deactivate_realmfrom zerver.actions.scheduled_messages import (@@ -25,6 +26,13 @@ if TYPE_CHECKING:class RemindersTest(ZulipTestCase):+ @override+ def setUp(self) -> None:+ super().setUp()+ # populate_db schedules messages for a year after the test+ # database was built, which may already be due.+ ScheduledMessage.objects.all().delete()+def do_schedule_reminder(self,message_id: int,diff --git a/zerver/tests/test_scheduled_messages.py b/zerver/tests/test_scheduled_messages.pyindex 3015e98ddd8..36d20883fc7 100644--- a/zerver/tests/test_scheduled_messages.py+++ b/zerver/tests/test_scheduled_messages.py@@ -9,6 +9,7 @@ import orjsonimport time_machinefrom django.conf import settingsfrom django.utils.timezone import now as timezone_now+from typing_extensions import overridefrom zerver.actions.scheduled_messages import (SCHEDULED_MESSAGE_LATE_CUTOFF_MINUTES,@@ -28,6 +29,13 @@ if TYPE_CHECKING:class ScheduledMessageTest(ZulipTestCase):+ @override+ def setUp(self) -> None:+ super().setUp()+ # populate_db schedules messages for a year after the test+ # database was built, which may already be due.+ ScheduledMessage.objects.all().delete()+def last_scheduled_message(self) -> ScheduledMessage:return ScheduledMessage.objects.all().order_by("-id")[0]diff --git a/zerver/tests/test_user_groups.py b/zerver/tests/test_user_groups.pyindex e89f5e69bc5..931c8aac94e 100644--- a/zerver/tests/test_user_groups.py+++ b/zerver/tests/test_user_groups.py@@ -2765,11 +2765,10 @@ class UserGroupAPITestCase(UserGroupTestCase):full_members_group,acting_user=None,)- do_set_realm_property(realm, "waiting_period_threshold", 10, acting_user=None)-othello = self.example_user("othello")othello.date_joined = timezone_now() - timedelta(days=9)othello.save()+ do_set_realm_property(realm, "waiting_period_threshold", 10, acting_user=None)check_create_user_group("othello", "Insufficient permission")@@ -3130,10 +3129,11 @@ class UserGroupAPITestCase(UserGroupTestCase):full_members_group,acting_user=None,)- do_set_realm_property(realm, "waiting_period_threshold", 10, acting_user=None)-othello.date_joined = timezone_now() - timedelta(days=9)othello.save()+ cordelia.date_joined = timezone_now() - timedelta(days=9)+ cordelia.save()+ do_set_realm_property(realm, "waiting_period_threshold", 10, acting_user=None)promote_new_full_members()check_adding_members_to_group("cordelia", "Insufficient permission")