Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
settings: Add PREFER_DIRECT_MESSAGE_GROUP to dev environment.
Alex Vandiver4921d7bd7953
diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.pyindex 27511c2f9a6..9b1ed117461 100644--- a/corporate/tests/test_stripe.py+++ b/corporate/tests/test_stripe.py@@ -22,6 +22,7 @@ import stripeimport time_machinefrom django.conf import settingsfrom django.core import signing+from django.test import override_settingsfrom django.urls.resolvers import get_resolverfrom django.utils.crypto import get_random_stringfrom django.utils.timezone import now as timezone_now@@ -7439,6 +7440,7 @@ class TestSupportBillingHelpers(StripeTestCase):}self.assertEqual(realm_audit_log.extra_data, expected_extra_data)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_approve_realm_sponsorship(self) -> None:realm = get_realm("zulip")self.assertNotEqual(realm.plan_type, Realm.PLAN_TYPE_STANDARD_FREE)diff --git a/zerver/tests/test_channel_fetch.py b/zerver/tests/test_channel_fetch.pyindex ad859f6542b..f42f7709440 100644--- a/zerver/tests/test_channel_fetch.py+++ b/zerver/tests/test_channel_fetch.py@@ -857,6 +857,7 @@ class GetSubscribersTest(ZulipTestCase):self.assert_length(sub["partial_subscribers"], 3)self.assertIsNone(sub.get("subscribers"))+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_gather_subscriptions(self) -> None:"""gather_subscriptions returns correct results with only 3 queriesdiff --git a/zerver/tests/test_email_mirror.py b/zerver/tests/test_email_mirror.pyindex cc56acbb148..dd49d67eadf 100644--- a/zerver/tests/test_email_mirror.py+++ b/zerver/tests/test_email_mirror.py@@ -1305,7 +1305,7 @@ class TestMissedMessageEmailMessages(ZulipTestCase):incoming_valid_message["To"] = mm_addressincoming_valid_message["Reply-to"] = self.example_email("othello")- with self.assert_database_query_count(17):+ with self.assert_database_query_count(18):process_message(incoming_valid_message)# confirm that Hamlet got the messagediff --git a/zerver/tests/test_event_system.py b/zerver/tests/test_event_system.pyindex 73ef47afea5..a0bf7a3a63a 100644--- a/zerver/tests/test_event_system.py+++ b/zerver/tests/test_event_system.py@@ -376,6 +376,7 @@ class GetEventsTest(ZulipTestCase):request = HostRequestMock(post_data, user_profile, tornado_handler=dummy_handler)return view_func(request, user_profile)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_get_events(self) -> None:user_profile = self.example_user("hamlet")email = user_profile.email@@ -516,6 +517,7 @@ class GetEventsTest(ZulipTestCase):self.assertTrue("local_message_id" not in recipient_events[1])self.assertEqual(recipient_events[1]["message"]["recipient_id"], user_profile.recipient_id)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_get_events_narrow(self) -> None:user_profile = self.example_user("hamlet")self.login_user(user_profile)diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.pyindex 288e120dcc7..39ce1d463f3 100644--- a/zerver/tests/test_events.py+++ b/zerver/tests/test_events.py@@ -17,6 +17,7 @@ from unittest import mockimport orjsonimport time_machinefrom dateutil.parser import parse as dateparser+from django.test import override_settingsfrom django.utils.timezone import now as timezone_nowfrom typing_extensions import override@@ -702,6 +703,7 @@ class NormalActionsTest(BaseAction):is_embedded_update_only=False,)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_pm_send_message_events_via_direct_message_group(self) -> None:hamlet = self.example_user("hamlet")cordelia = self.example_user("cordelia")@@ -717,6 +719,7 @@ class NormalActionsTest(BaseAction):skip_capture_on_commit_callbacks=True,)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_direct_message_group_send_message_events(self) -> None:direct_message_group = [self.example_user("hamlet"),diff --git a/zerver/tests/test_example.py b/zerver/tests/test_example.pyindex 9b99b99e47e..216fbe900c5 100644--- a/zerver/tests/test_example.py+++ b/zerver/tests/test_example.py@@ -3,6 +3,7 @@ from unittest import mockimport orjsonimport time_machine+from django.test import override_settingsfrom django.utils.timezone import now as timezone_nowfrom zerver.actions.realm_settings import do_change_realm_permission_group_setting@@ -350,6 +351,7 @@ class TestMessageHelpers(ZulipTestCase):class TestQueryCounts(ZulipTestCase):+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_capturing_queries(self) -> None:# It's a common pitfall in Django to accidentally perform# database queries in a loop, due to lazy evaluation of@@ -364,7 +366,7 @@ class TestQueryCounts(ZulipTestCase):hamlet = self.example_user("hamlet")cordelia = self.example_user("cordelia")- with self.assert_database_query_count(16):+ with self.assert_database_query_count(17):self.send_personal_message(from_user=hamlet,to_user=cordelia,diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.pyindex ce81392014f..9cc8a1c446f 100644--- a/zerver/tests/test_home.py+++ b/zerver/tests/test_home.py@@ -610,7 +610,7 @@ class HomeTest(ZulipTestCase):# Should be successful after calling 2fa login function.self.check_rendered_logged_in_app(result)- @override_settings(TERMS_OF_SERVICE_VERSION=None)+ @override_settings(TERMS_OF_SERVICE_VERSION=None, PREFER_DIRECT_MESSAGE_GROUP=True)def test_num_queries_for_realm_admin(self) -> None:# Verify number of queries for Realm admin isn't much higher than for normal users.self.login("iago")diff --git a/zerver/tests/test_import_export.py b/zerver/tests/test_import_export.pyindex b7be9620218..e8e33e6913a 100644--- a/zerver/tests/test_import_export.py+++ b/zerver/tests/test_import_export.py@@ -894,6 +894,7 @@ class RealmImportExportTest(ExportFile):exported_huddle_ids = self.get_set(realm_data["zerver_huddle"], "id")self.assertEqual(exported_huddle_ids, set())+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_export_realm_with_member_consent(self) -> None:realm = Realm.objects.get(string_id="zulip")diff --git a/zerver/tests/test_invite.py b/zerver/tests/test_invite.pyindex 9b4fc635550..ce914d03430 100644--- a/zerver/tests/test_invite.py+++ b/zerver/tests/test_invite.py@@ -1372,6 +1372,7 @@ [email protected]""",])+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_direct_notification_for_accepted_invitation(self) -> None:"""New test to check if notification-bot message is sent to the referrerdiff --git a/zerver/tests/test_mattermost_importer.py b/zerver/tests/test_mattermost_importer.pyindex 2bf8bfe6e96..300b0625845 100644--- a/zerver/tests/test_mattermost_importer.py+++ b/zerver/tests/test_mattermost_importer.py@@ -723,6 +723,7 @@ class MatterMostImporter(MattermostImportTestBase):{malfoy_id, pansy_id},)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=False)def test_convert_direct_message_group_data(self) -> None:fixture_file_name = self.fixture_file_name("export.json", "mattermost_fixtures/direct_channel"@@ -1237,6 +1238,7 @@ class MatterMostImporter(MattermostImportTestBase):self.verify_emoji_code_foreign_keys()+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=False)def test_do_convert_data_with_direct_messages(self) -> None:mattermost_data_dir = self.fixture_file_name("direct_channel", "mattermost_fixtures")output_dir = self.make_import_output_dir("mattermost")diff --git a/zerver/tests/test_message_delete.py b/zerver/tests/test_message_delete.pyindex 81a4771cf69..f5cadd63c68 100644--- a/zerver/tests/test_message_delete.py+++ b/zerver/tests/test_message_delete.py@@ -4,6 +4,7 @@ from unittest import mockimport orjsonfrom django.db import IntegrityError+from django.test import override_settingsfrom django.utils.timezone import now as timezone_nowfrom zerver.actions.message_delete import do_delete_messages@@ -240,6 +241,7 @@ class DeleteMessageTest(ZulipTestCase):self.assertCountEqual([first_msg_id, second_msg_id], events[1]["event"]["message_ids"])self.assertCountEqual([cordelia.id, iago.id], events[1]["users"])+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_do_delete_messages_grouping_logic(self) -> None:realm = get_realm("zulip")cordelia = self.example_user("cordelia")diff --git a/zerver/tests/test_message_dict.py b/zerver/tests/test_message_dict.pyindex 49570862f75..9564d3fe689 100644--- a/zerver/tests/test_message_dict.py+++ b/zerver/tests/test_message_dict.py@@ -1,6 +1,7 @@from typing import Anyfrom unittest import mock+from django.test import override_settingsfrom django.utils.timezone import now as timezone_nowfrom zerver.lib.cache import cache_delete, to_dict_cache_key_id@@ -141,6 +142,7 @@ class MessageDictTest(ZulipTestCase):self.assertEqual(send_message_payload, fetch_payload)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_bulk_message_fetching(self) -> None:sender = self.example_user("othello")receiver = self.example_user("hamlet")diff --git a/zerver/tests/test_message_edit.py b/zerver/tests/test_message_edit.pyindex 84bb395d34a..6eff0f5ad55 100644--- a/zerver/tests/test_message_edit.py+++ b/zerver/tests/test_message_edit.py@@ -5,6 +5,7 @@ from unittest import mockimport orjsonimport time_machine+from django.test import override_settingsfrom django.utils.timezone import now as timezone_nowfrom zerver.actions.message_edit import get_mentions_for_message_updates@@ -219,6 +220,7 @@ class EditMessageTest(ZulipTestCase):self.assert_json_success(result)self.assertEqual(Message.objects.get(id=msg_id).topic_name(), "edited")+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_fetch_message_from_id(self) -> None:hamlet = self.example_user("hamlet")cordelia = self.example_user("cordelia")diff --git a/zerver/tests/test_message_fetch.py b/zerver/tests/test_message_fetch.pyindex 2e8a687c984..d5026ded92c 100644--- a/zerver/tests/test_message_fetch.py+++ b/zerver/tests/test_message_fetch.py@@ -2569,7 +2569,6 @@ class GetOldMessagesTest(ZulipTestCase):result = self.get_and_check_messages(dict(narrow=orjson.dumps(narrow).decode()))self.assertNotEqual(result["messages"], [])- @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_get_1_to_1_messages_with_existent_group_dm(self) -> None:me = self.example_user("hamlet")other_user = self.example_user("iago")@@ -2594,7 +2593,6 @@ class GetOldMessagesTest(ZulipTestCase):self.assertIn(message["id"], message_ids)self.assertEqual(message["recipient_id"], direct_message_group.recipient_id)- @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_get_messages_to_self_with_existent_group_dm(self) -> None:me = self.example_user("hamlet")diff --git a/zerver/tests/test_message_report.py b/zerver/tests/test_message_report.pyindex a910db5cd03..99f1c04a12c 100644--- a/zerver/tests/test_message_report.py+++ b/zerver/tests/test_message_report.py@@ -471,8 +471,8 @@ class ReportMessageTest(ZulipTestCase):submitted_report=reports.last(),)- @time_machine.travel(MOCKED_DATE_SENT, tick=False)@override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)+ @time_machine.travel(MOCKED_DATE_SENT, tick=False)def test_personal_message_report_using_direct_message_group(self) -> None:dm_recipient = self.hamletdirect_message_group = get_or_create_direct_message_group(diff --git a/zerver/tests/test_message_send.py b/zerver/tests/test_message_send.pyindex 2f2b6905379..5f8120babb7 100644--- a/zerver/tests/test_message_send.py+++ b/zerver/tests/test_message_send.py@@ -2741,7 +2741,6 @@ class PersonalMessageSendTest(ZulipTestCase):recipient = Recipient.objects.get(type_id=user_profile.id, type=Recipient.PERSONAL)self.assertEqual(most_recent_message(user_profile).recipient, recipient)- @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_personal_to_self_using_direct_message_group(self) -> None:"""If you send a personal to yourself using direct_message_group, only you see it.@@ -2810,7 +2809,6 @@ class PersonalMessageSendTest(ZulipTestCase):receiver=self.example_user("othello"),)- @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_personal_using_direct_message_group(self) -> None:"""If you send a personal using direct_message_group, only you and the recipient see it.@@ -2886,7 +2884,7 @@ class PersonalMessageSendTest(ZulipTestCase):# Have the administrator send a message, and verify that allows the user to reply.self.send_personal_message(admin, user_profile)- with self.assert_database_query_count(16):+ with self.assert_database_query_count(17):self.send_personal_message(user_profile, admin)# Tests that user cannot initiate direct message thread in groups.@@ -2922,7 +2920,7 @@ class PersonalMessageSendTest(ZulipTestCase):user_group,acting_user=None,)- with self.assert_database_query_count(16):+ with self.assert_database_query_count(17):self.send_personal_message(user_profile, cordelia)# Test that query count decreases if setting is set to a system group.@@ -2936,7 +2934,7 @@ class PersonalMessageSendTest(ZulipTestCase):acting_user=None,)othello = self.example_user("othello")- with self.assert_database_query_count(15):+ with self.assert_database_query_count(16):self.send_personal_message(user_profile, othello)def test_direct_message_permission_group_setting(self) -> None:@@ -2964,7 +2962,7 @@ class PersonalMessageSendTest(ZulipTestCase):acting_user=None,)# Tests if the user is allowed to send to administrators.- with self.assert_database_query_count(16):+ with self.assert_database_query_count(17):self.send_personal_message(user_profile, admin)self.send_personal_message(admin, user_profile)# Tests if we can send messages to self irrespective of the value of the setting.@@ -3014,7 +3012,7 @@ class PersonalMessageSendTest(ZulipTestCase):with self.assertRaises(DirectMessagePermissionError):self.send_personal_message(cordelia, polonius)- with self.assert_database_query_count(16):+ with self.assert_database_query_count(17):self.send_personal_message(user_profile, cordelia)# Test that query count decreases if setting is set to a system group.@@ -3027,7 +3025,7 @@ class PersonalMessageSendTest(ZulipTestCase):members_group,acting_user=None,)- with self.assert_database_query_count(15):+ with self.assert_database_query_count(16):self.send_personal_message(user_profile, cordelia)do_change_realm_permission_group_setting(diff --git a/zerver/tests/test_outgoing_webhook_system.py b/zerver/tests/test_outgoing_webhook_system.pyindex 5d4b400267b..bcf13afc9be 100644--- a/zerver/tests/test_outgoing_webhook_system.py+++ b/zerver/tests/test_outgoing_webhook_system.py@@ -4,6 +4,7 @@ from unittest import mockimport orjsonimport requestsimport responses+from django.test import override_settingsfrom version import ZULIP_VERSIONfrom zerver.actions.create_user import do_create_user@@ -118,6 +119,7 @@ class DoRestCallTests(ZulipTestCase):_helper("")_helper(None)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_retry_request(self) -> None:bot_user = self.example_user("outgoing_webhook_bot")mock_event = self.mock_event(bot_user)@@ -179,6 +181,7 @@ The webhook got a response with status code *500*.""",self.assertEqual(resp, None)self.assert_length(logs.output, 1)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_fail_request(self) -> None:bot_user = self.example_user("outgoing_webhook_bot")mock_event = self.mock_event(bot_user)@@ -240,6 +243,7 @@ The webhook got a response with status code *400*.""",}self.assertLessEqual(headers.items(), prepared_request.headers.items())+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_error_handling(self) -> None:bot_user = self.example_user("outgoing_webhook_bot")mock_event = self.mock_event(bot_user)@@ -270,6 +274,7 @@ The webhook got a response with status code *400*.""",self.assertEqual(i.output, log_output)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_request_exception(self) -> None:bot_user = self.example_user("outgoing_webhook_bot")mock_event = self.mock_event(bot_user)@@ -302,6 +307,7 @@ I'm a generic exception :(assert bot_user.bot_owner is not Noneself.assertEqual(bot_owner_notification.recipient_id, bot_user.bot_owner.recipient_id)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_jsonable_exception(self) -> None:bot_user = self.example_user("outgoing_webhook_bot")mock_event = self.mock_event(bot_user)@@ -331,6 +337,7 @@ The outgoing webhook server attempted to send a message in Zulip, but that requeassert bot_user.bot_owner is not Noneself.assertEqual(bot_owner_notification.recipient_id, bot_user.bot_owner.recipient_id)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_invalid_response_format(self) -> None:bot_user = self.example_user("outgoing_webhook_bot")mock_event = self.mock_event(bot_user)@@ -358,6 +365,7 @@ The outgoing webhook server attempted to send a message in Zulip, but that requeassert bot_user.bot_owner is not Noneself.assertEqual(bot_owner_notification.recipient_id, bot_user.bot_owner.recipient_id)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_invalid_json_in_response(self) -> None:bot_user = self.example_user("outgoing_webhook_bot")mock_event = self.mock_event(bot_user)@@ -466,6 +474,7 @@ class TestOutgoingWebhookMessaging(ZulipTestCase):self.assertEqual(qotd_req["message"]["content"], "some content")self.assertEqual(qotd_req["message"]["sender_id"], sender.id)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)@responses.activatedef test_pm_to_outgoing_webhook_bot(self) -> None:bot_owner = self.example_user("othello")@@ -496,6 +505,7 @@ class TestOutgoingWebhookMessaging(ZulipTestCase):Recipient.PERSONAL,)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)@responses.activatedef test_pm_to_outgoing_webhook_bot_for_407_error_code(self) -> None:bot_owner = self.example_user("othello")@@ -564,6 +574,7 @@ class TestOutgoingWebhookMessaging(ZulipTestCase):self.assertEqual(last_message.topic_name(), "bar")self.assert_message_stream_name(last_message, "Denmark")+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)@responses.activatedef test_stream_message_failure_to_outgoing_webhook_bot(self) -> None:realm = get_realm("zulip")diff --git a/zerver/tests/test_realm_creation.py b/zerver/tests/test_realm_creation.pyindex 0fddbc56f45..5cb84a817c4 100644--- a/zerver/tests/test_realm_creation.py+++ b/zerver/tests/test_realm_creation.py@@ -35,7 +35,9 @@ from zerver.models.users import get_system_bot, get_userclass DemoCreationTest(ZulipTestCase):- @override_settings(OPEN_REALM_CREATION=True, DEMO_ORG_DEADLINE_DAYS=30)+ @override_settings(+ OPEN_REALM_CREATION=True, DEMO_ORG_DEADLINE_DAYS=30, PREFER_DIRECT_MESSAGE_GROUP=True+ )def test_create_demo_organization(self) -> None:internal_realm = get_realm(settings.SYSTEM_BOT_REALM)notification_bot = get_system_bot(settings.NOTIFICATION_BOT, internal_realm.id)@@ -606,7 +608,7 @@ class RealmCreationTest(ZulipTestCase):self.assertEqual(user.realm, realm)self.assertFalse(user.enable_marketing_emails)- @override_settings(OPEN_REALM_CREATION=True)+ @override_settings(OPEN_REALM_CREATION=True, PREFER_DIRECT_MESSAGE_GROUP=True)def test_create_regular_realm_welcome_bot_direct_message(self) -> None:password = "test"string_id = "custom-test"@@ -671,7 +673,7 @@ class RealmCreationTest(ZulipTestCase):self.assertTrue(welcome_msg.content.startswith("Hello, and welcome to Zulip!"))self.assertNotIn("I've kicked off some conversations", welcome_msg.content)- @override_settings(OPEN_REALM_CREATION=True)+ @override_settings(OPEN_REALM_CREATION=True, PREFER_DIRECT_MESSAGE_GROUP=True)def test_create_education_organization_welcome_bot_direct_message(self) -> None:password = "test"string_id = "custom-test"@@ -721,7 +723,7 @@ class RealmCreationTest(ZulipTestCase):self.assertNotIn("getting started guide", welcome_msg.content)self.assertIn("using Zulip for a class guide", welcome_msg.content)- @override_settings(OPEN_REALM_CREATION=True)+ @override_settings(OPEN_REALM_CREATION=True, PREFER_DIRECT_MESSAGE_GROUP=True)def test_create_realm_with_custom_language(self) -> None:email = "[email protected]"password = "test"diff --git a/zerver/tests/test_rocketchat_importer.py b/zerver/tests/test_rocketchat_importer.pyindex 694ba88a181..fdcb530f3f7 100644--- a/zerver/tests/test_rocketchat_importer.py+++ b/zerver/tests/test_rocketchat_importer.py@@ -204,6 +204,7 @@ class RocketChatImporter(ZulipTestCase):expected_error_message = f"['Invalid email format, please fix the following email(s) and try again: {bad_email1}, {bad_email2}']"self.assertEqual(error_message, expected_error_message)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=False)def test_categorize_channels_and_map_with_id(self) -> None:fixture_dir_name = self.fixture_file_name("", "rocketchat_fixtures")rocketchat_data = rocketchat_data_to_dict(fixture_dir_name)@@ -450,6 +451,7 @@ class RocketChatImporter(ZulipTestCase):self.assert_length(subscriber_handler.get_users(stream_id=zerver_stream[6]["id"]), 0)self.assertFalse(zerver_stream[6]["deactivated"])+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=False)def test_convert_direct_message_group_data(self) -> None:fixture_dir_name = self.fixture_file_name("", "rocketchat_fixtures")rocketchat_data = rocketchat_data_to_dict(fixture_dir_name)@@ -639,6 +641,7 @@ class RocketChatImporter(ZulipTestCase):# Verify the filename was sanitized to remove path separators.self.assertEqual(zerver_realmemoji[0]["file_name"], "......etcmalicious.png")+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=False)def test_map_receiver_id_to_recipient_id(self) -> None:fixture_dir_name = self.fixture_file_name("", "rocketchat_fixtures")rocketchat_data = rocketchat_data_to_dict(fixture_dir_name)@@ -741,6 +744,7 @@ class RocketChatImporter(ZulipTestCase):zerver_recipient[12]["id"],)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=False)def test_separate_channel_private_and_livechat_messages(self) -> None:fixture_dir_name = self.fixture_file_name("", "rocketchat_fixtures")rocketchat_data = rocketchat_data_to_dict(fixture_dir_name)@@ -998,6 +1002,7 @@ class RocketChatImporter(ZulipTestCase):with open(full_path, "rb") as f:return orjson.loads(f.read())+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=False)def test_do_convert_data(self) -> None:rocketchat_data_dir = self.fixture_file_name("", "rocketchat_fixtures")output_dir = self.make_import_output_dir("rocketchat")diff --git a/zerver/tests/test_scheduled_messages.py b/zerver/tests/test_scheduled_messages.pyindex 9f52b8d1999..dc7696ae9e0 100644--- a/zerver/tests/test_scheduled_messages.py+++ b/zerver/tests/test_scheduled_messages.py@@ -301,6 +301,7 @@ class ScheduledMessageTest(ZulipTestCase):)self.assertTrue(scheduled_message.failed)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_too_late_to_deliver_scheduled_message(self) -> None:expected_failure_message = "Message could not be sent at the scheduled time."self.create_scheduled_message()diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.pyindex edd06441763..ee8a1306f17 100644--- a/zerver/tests/test_signup.py+++ b/zerver/tests/test_signup.py@@ -392,6 +392,7 @@ class AddNewUserHistoryTest(ZulipTestCase):self.assertFalse(user_message.flags.read.is_set)self.assertFalse(user_message.flags.historical.is_set)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_tracked_onboarding_topics_first_messages_marked_starred(self) -> None:"""Realms with tracked onboarding messages have only@@ -442,6 +443,7 @@ class AddNewUserHistoryTest(ZulipTestCase):)self.assertTrue(initial_direct_user_message.flags.starred.is_set)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_auto_subbed_to_personals(self) -> None:"""Newly created users are auto-subbed to the ability to receive@@ -1049,6 +1051,7 @@ class LoginTest(ZulipTestCase):self.assert_in_response("Please try a different URL", result)self.assert_logged_in_user_id(None)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_register(self) -> None:reset_email_visibility_to_everyone_in_zulip_realm()@@ -1067,7 +1070,7 @@ class LoginTest(ZulipTestCase):# to sending messages, such as getting the welcome bot, looking up# the alert words for a realm, etc.with (- self.assert_database_query_count(96),+ self.assert_database_query_count(97),self.assert_memcached_count(18),self.captureOnCommitCallbacks(execute=True),):@@ -3576,7 +3579,7 @@ class UserSignUpTest(ZulipTestCase):assert user_profile is not Noneself.assert_logged_in_user_id(user_profile.id)- @override_settings(TERMS_OF_SERVICE_VERSION=None)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True, TERMS_OF_SERVICE_VERSION=None)def test_dev_user_registration_create_demo_realm(self) -> None:result = self.client_post("/devtools/register_demo_realm/")self.assertEqual(result.status_code, 302)diff --git a/zerver/tests/test_slack_importer.py b/zerver/tests/test_slack_importer.pyindex 53a7a8e4b9d..05bed8dcba2 100644--- a/zerver/tests/test_slack_importer.py+++ b/zerver/tests/test_slack_importer.py@@ -1008,7 +1008,8 @@ class SlackImporter(ZulipTestCase):self.assertEqual(zerver_subscription[1]["recipient"], zerver_subscription[3]["recipient"])self.assertEqual(zerver_subscription[1]["pin_to_top"], False)- def test_channels_to_zerver_stream(self) -> None:+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=False)+ def test_channels_to_zerver_stream_using_personal_recipient(self) -> None:slack_user_id_to_zulip_user_id = {"U061A1R2R": 1,"U061A3E0G": 8,@@ -1332,7 +1333,10 @@ class SlackImporter(ZulipTestCase):self.assertEqual(zerver_usermessage[3]["message"], message_id)@mock.patch("zerver.data_import.slack.build_usermessages", return_value=(2, 4))- def test_channel_message_to_zerver_message(self, mock_build_usermessage: mock.Mock) -> None:+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=False)+ def test_channel_message_to_zerver_message_using_personal_recipient(+ self, mock_build_usermessage: mock.Mock+ ) -> None:user_data = [{"id": "U066MTL5U", "name": "john doe", "deleted": False, "real_name": "John"},{"id": "U061A5N1G", "name": "jane doe", "deleted": False, "real_name": "Jane"},@@ -1585,8 +1589,8 @@ class SlackImporter(ZulipTestCase):self.assertEqual(zerver_message[9]["has_link"], True)self.assertTrue(zerver_message[9]["content"].startswith("Look!\n[Apple](/user_uploads/"))- @mock.patch("zerver.data_import.slack.build_usermessages", return_value=(2, 4))@override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)+ @mock.patch("zerver.data_import.slack.build_usermessages", return_value=(2, 4))def test_channel_message_to_zerver_message_using_direct_message_group(self, mock_build_usermessage: mock.Mock) -> None:diff --git a/zerver/tests/test_users.py b/zerver/tests/test_users.pyindex 959871e59e1..58a080625d1 100644--- a/zerver/tests/test_users.py+++ b/zerver/tests/test_users.py@@ -1138,7 +1138,7 @@ class QueryCountTest(ZulipTestCase):prereg_user = PreregistrationUser.objects.get(email="[email protected]")with (- self.assert_database_query_count(86),+ self.assert_database_query_count(88),self.assert_memcached_count(23),self.capture_send_event_calls(expected_num_events=11) as events,):diff --git a/zerver/tests/test_zulip_update_announcements.py b/zerver/tests/test_zulip_update_announcements.pyindex 98a77946c21..b5a55629436 100644--- a/zerver/tests/test_zulip_update_announcements.py+++ b/zerver/tests/test_zulip_update_announcements.py@@ -4,6 +4,7 @@ from unittest import mockimport time_machinefrom django.conf import settings+from django.test import override_settingsfrom django.utils.timezone import now as timezone_nowfrom typing_extensions import override@@ -405,6 +406,7 @@ class ZulipUpdateAnnouncementsTest(ZulipTestCase):)self.assertEqual(remove_single_newlines(input_text), expected_output)+ @override_settings(PREFER_DIRECT_MESSAGE_GROUP=True)def test_zulip_updates_for_realm_imported_from_other_product(self) -> None:with mock.patch("zerver.lib.zulip_update_announcements.zulip_update_announcements",diff --git a/zproject/dev_settings.py b/zproject/dev_settings.pyindex aafcf8a7ec5..21c79f80ea0 100644--- a/zproject/dev_settings.py+++ b/zproject/dev_settings.py@@ -237,6 +237,8 @@ INPUT_COST_PER_GIGATOKEN = 790MAX_PER_USER_MONTHLY_AI_COST = 1MAX_WEB_DATA_IMPORT_SIZE_MB = 1024+PREFER_DIRECT_MESSAGE_GROUP = True+# We override some rate limiting rules in development, when they prove# excessively limiting for development and testing purposes.RATE_LIMITING_RULES = {