From c1f1dc4b25844caca56403c7e2e3f5c5ced911c4 Mon Sep 17 00:00:00 2001 From: Lauryn Menard Date: Tue, 16 Apr 2024 17:58:08 +0200 Subject: [PATCH] message-send: Update translated errors for stream to channel rename. In zerver/actions/message_send.py, updates translated error strings to use channel instead of stream. Also, updates the messages sent to bot owners when a stream doesn't exist or has no subscribers. Part of stream to channel rename project. --- zerver/actions/message_send.py | 14 +++++++------- zerver/tests/test_message_send.py | 14 +++++++------- zerver/tests/test_outgoing_webhook_system.py | 2 +- zerver/webhooks/helloworld/tests.py | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/zerver/actions/message_send.py b/zerver/actions/message_send.py index e2b0260c6a..89736db589 100644 --- a/zerver/actions/message_send.py +++ b/zerver/actions/message_send.py @@ -1260,7 +1260,7 @@ def extract_stream_indicator(s: str) -> Union[str, int]: # once we improve our documentation. if isinstance(data, list): if len(data) != 1: # nocoverage - raise JsonableError(_("Expected exactly one stream")) + raise JsonableError(_("Expected exactly one channel")) data = data[0] if isinstance(data, str): @@ -1271,7 +1271,7 @@ def extract_stream_indicator(s: str) -> Union[str, int]: # We had a stream id. return data - raise JsonableError(_("Invalid data type for stream")) + raise JsonableError(_("Invalid data type for channel")) def extract_private_recipients(s: str) -> Union[List[str], List[int]]: @@ -1463,8 +1463,8 @@ def send_pm_if_empty_stream( "channel_id": stream_id, } content = _( - "Your bot {bot_identity} tried to send a message to stream ID " - "{channel_id}, but there is no stream with that ID." + "Your bot {bot_identity} tried to send a message to channel ID " + "{channel_id}, but there is no channel with that ID." ).format(**arg_dict) else: assert stream_name is not None @@ -1474,8 +1474,8 @@ def send_pm_if_empty_stream( "new_channel_link": "#streams/new", } content = _( - "Your bot {bot_identity} tried to send a message to stream " - "{channel_name}, but that stream does not exist. " + "Your bot {bot_identity} tried to send a message to channel " + "{channel_name}, but that channel does not exist. " "Click [here]({new_channel_link}) to create it." ).format(**arg_dict) else: @@ -1487,7 +1487,7 @@ def send_pm_if_empty_stream( } content = _( "Your bot {bot_identity} tried to send a message to " - "stream {channel_name}. The stream exists but " + "channel {channel_name}. The channel exists but " "does not have any subscribers." ).format(**arg_dict) diff --git a/zerver/tests/test_message_send.py b/zerver/tests/test_message_send.py index 242fc61ee8..24ace18241 100644 --- a/zerver/tests/test_message_send.py +++ b/zerver/tests/test_message_send.py @@ -140,7 +140,7 @@ class MessagePOSTTest(ZulipTestCase): msg = self.get_last_message() expected = ( "Your bot `whatever-bot@zulip.testserver` tried to send a message to " - "stream ID 99999, but there is no stream with that ID." + "channel ID 99999, but there is no channel with that ID." ) self.assertEqual(msg.content, expected) @@ -175,7 +175,7 @@ class MessagePOSTTest(ZulipTestCase): msg = self.get_second_to_last_message() expected = ( "Your bot `whatever-bot@zulip.testserver` tried to send a message to " - "stream #**Acropolis**. The stream exists but does not have any subscribers." + "channel #**Acropolis**. The channel exists but does not have any subscribers." ) self.assertEqual(msg.content, expected) @@ -210,7 +210,7 @@ class MessagePOSTTest(ZulipTestCase): msg = self.get_second_to_last_message() expected = ( "Your bot `whatever-bot@zulip.testserver` tried to send a message to " - "stream #**Acropolis**. The stream exists but does not have any subscribers." + "channel #**Acropolis**. The channel exists but does not have any subscribers." ) self.assertEqual(msg.content, expected) @@ -2428,13 +2428,13 @@ class ExtractTest(ZulipTestCase): 123, ) - with self.assertRaisesRegex(JsonableError, "Invalid data type for stream"): + with self.assertRaisesRegex(JsonableError, "Invalid data type for channel"): extract_stream_indicator("{}") - with self.assertRaisesRegex(JsonableError, "Invalid data type for stream"): + with self.assertRaisesRegex(JsonableError, "Invalid data type for channel"): extract_stream_indicator("[{}]") - with self.assertRaisesRegex(JsonableError, "Expected exactly one stream"): + with self.assertRaisesRegex(JsonableError, "Expected exactly one channel"): extract_stream_indicator('[1,2,"general"]') def test_extract_private_recipients_emails(self) -> None: @@ -3053,7 +3053,7 @@ class CheckMessageTest(ZulipTestCase): new_count = message_stream_count(parent) self.assertEqual(new_count, old_count + 1) - self.assertIn("that stream does not exist.", most_recent_message(parent).content) + self.assertIn("that channel does not exist.", most_recent_message(parent).content) # Try sending to stream that exists with no subscribers soon # after; due to rate-limiting, this should send nothing. diff --git a/zerver/tests/test_outgoing_webhook_system.py b/zerver/tests/test_outgoing_webhook_system.py index 2a9620e4dd..233ff9c041 100644 --- a/zerver/tests/test_outgoing_webhook_system.py +++ b/zerver/tests/test_outgoing_webhook_system.py @@ -635,7 +635,7 @@ class TestOutgoingWebhookMessaging(ZulipTestCase): prev_message = self.get_second_to_last_message() self.assertIn( - "tried to send a message to stream #**Denmark**, but that stream does not exist", + "tried to send a message to channel #**Denmark**, but that channel does not exist", prev_message.content, ) diff --git a/zerver/webhooks/helloworld/tests.py b/zerver/webhooks/helloworld/tests.py index 0ec9f0327a..071c7f1ead 100644 --- a/zerver/webhooks/helloworld/tests.py +++ b/zerver/webhooks/helloworld/tests.py @@ -54,7 +54,7 @@ class HelloWorldHookTests(WebhookTestCase): self.url = self.build_webhook_url() realm = get_realm("zulip") notification_bot = get_system_bot(settings.NOTIFICATION_BOT, realm.id) - expected_message = "Your bot `webhook-bot@zulip.com` tried to send a message to stream #**nonexistent**, but that stream does not exist. Click [here](#streams/new) to create it." + expected_message = "Your bot `webhook-bot@zulip.com` tried to send a message to channel #**nonexistent**, but that channel does not exist. Click [here](#streams/new) to create it." self.send_and_test_private_message( "goodbye", expected_message=expected_message,