From 1d209220dd9f0a6190f1457b3aa43d25c7763c07 Mon Sep 17 00:00:00 2001 From: Lauryn Menard Date: Thu, 11 May 2023 17:33:42 +0200 Subject: [PATCH] tests: Add coverage for error when editing a sent scheduled message. Adds test coverage for the error sent for editing a scheduled message that was successfully sent. `zerver/actions/scheduled_messages.py` now has 100% test coverage again. --- tools/test-backend | 1 - zerver/tests/test_scheduled_messages.py | 13 +++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/test-backend b/tools/test-backend index 8fabb694fe..0fcca806ba 100755 --- a/tools/test-backend +++ b/tools/test-backend @@ -78,7 +78,6 @@ not_yet_fully_covered = [ "zerver/actions/create_realm.py", "zerver/actions/message_edit.py", "zerver/actions/presence.py", - "zerver/actions/scheduled_messages.py", "zerver/lib/addressee.py", "zerver/lib/markdown/__init__.py", "zerver/lib/cache.py", diff --git a/zerver/tests/test_scheduled_messages.py b/zerver/tests/test_scheduled_messages.py index 9b31796956..0dc1b48dbe 100644 --- a/zerver/tests/test_scheduled_messages.py +++ b/zerver/tests/test_scheduled_messages.py @@ -190,6 +190,19 @@ class ScheduledMessageTest(ZulipTestCase): ) self.assertEqual(delivered_message.date_sent, more_than_scheduled_delivery_datetime) + # Check error is sent if an edit happens after the scheduled + # message is successfully sent. + new_delivery_datetime = timezone_now() + datetime.timedelta(minutes=7) + new_delivery_timestamp = int(new_delivery_datetime.timestamp()) + updated_response = self.do_schedule_message( + "direct", + [othello.id], + "New content!", + new_delivery_timestamp, + scheduled_message_id=str(scheduled_message.id), + ) + self.assert_json_error(updated_response, "Scheduled message was already sent") + def verify_deliver_scheduled_message_failure( self, scheduled_message: ScheduledMessage, logger: mock.Mock, expected_failure_message: str ) -> None: