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.
This commit is contained in:
Lauryn Menard 2023-05-11 17:33:42 +02:00 committed by Tim Abbott
parent 1019a74c6f
commit 1d209220dd
2 changed files with 13 additions and 1 deletions

View File

@ -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",

View File

@ -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: