From 15c6d67e9cc4e805071c3a9f2dde2857b16e3344 Mon Sep 17 00:00:00 2001 From: Lauryn Menard Date: Fri, 28 Apr 2023 13:35:00 +0200 Subject: [PATCH] populate-db: Add scheduled message to test database. Prep commit for adding the scheduled-message endpoints to the API documentation. Adds a scheduled message for Iago in the test database so that it can be deleted in the delete cURL example in the api-test suite. --- zerver/tests/test_home.py | 2 +- zilencer/management/commands/populate_db.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py index 3d638d0067..4593d89efa 100644 --- a/zerver/tests/test_home.py +++ b/zerver/tests/test_home.py @@ -440,7 +440,7 @@ class HomeTest(ZulipTestCase): # Verify number of queries for Realm admin isn't much higher than for normal users. self.login("iago") flush_per_request_caches() - with self.assert_database_query_count(46): + with self.assert_database_query_count(48): with patch("zerver.lib.cache.cache_set") as cache_mock: result = self._get_home_page() self.check_rendered_logged_in_app(result) diff --git a/zilencer/management/commands/populate_db.py b/zilencer/management/commands/populate_db.py index a2337311b9..73b5d59e9b 100644 --- a/zilencer/management/commands/populate_db.py +++ b/zilencer/management/commands/populate_db.py @@ -26,6 +26,7 @@ from zerver.actions.custom_profile_fields import ( ) from zerver.actions.message_send import build_message_send_dict, do_send_messages from zerver.actions.realm_emoji import check_add_realm_emoji +from zerver.actions.scheduled_messages import check_schedule_message from zerver.actions.streams import bulk_add_subscriptions from zerver.actions.user_groups import create_user_group_in_database from zerver.actions.users import do_change_user_role @@ -774,6 +775,19 @@ class Command(BaseCommand): {"id": pronouns.id, "value": "he/him"}, ], ) + # We need to create at least one scheduled message for Iago for the api-test + # cURL example to delete an existing scheduled message. + check_schedule_message( + sender=iago, + client=get_client("populate_db"), + recipient_type_name="stream", + message_to=[Stream.objects.get(name="Denmark", realm=zulip_realm).id], + topic_name="test-api", + message_content="It's time to celebrate the anniversary of provisioning this development environment :tada:!", + scheduled_message_id=None, + deliver_at=timezone_now() + timedelta(days=365), + realm=zulip_realm, + ) else: zulip_realm = get_realm("zulip") recipient_streams = [