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.
This commit is contained in:
Lauryn Menard 2023-04-28 13:35:00 +02:00 committed by Tim Abbott
parent bd2545b0d7
commit 15c6d67e9c
2 changed files with 15 additions and 1 deletions

View File

@ -440,7 +440,7 @@ class HomeTest(ZulipTestCase):
# Verify number of queries for Realm admin isn't much higher than for normal users. # Verify number of queries for Realm admin isn't much higher than for normal users.
self.login("iago") self.login("iago")
flush_per_request_caches() 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: with patch("zerver.lib.cache.cache_set") as cache_mock:
result = self._get_home_page() result = self._get_home_page()
self.check_rendered_logged_in_app(result) self.check_rendered_logged_in_app(result)

View File

@ -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.message_send import build_message_send_dict, do_send_messages
from zerver.actions.realm_emoji import check_add_realm_emoji 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.streams import bulk_add_subscriptions
from zerver.actions.user_groups import create_user_group_in_database from zerver.actions.user_groups import create_user_group_in_database
from zerver.actions.users import do_change_user_role from zerver.actions.users import do_change_user_role
@ -774,6 +775,19 @@ class Command(BaseCommand):
{"id": pronouns.id, "value": "he/him"}, {"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: else:
zulip_realm = get_realm("zulip") zulip_realm = get_realm("zulip")
recipient_streams = [ recipient_streams = [