diff --git a/analytics/tests/test_stats_views.py b/analytics/tests/test_stats_views.py index 7e85ec0b48..e4da601875 100644 --- a/analytics/tests/test_stats_views.py +++ b/analytics/tests/test_stats_views.py @@ -306,7 +306,7 @@ class TestGetChartData(ZulipTestCase): }, subdomain="zephyr", ) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") def test_include_empty_subgroups(self) -> None: FillState.objects.create( diff --git a/zerver/actions/streams.py b/zerver/actions/streams.py index 115519dd95..618ba1ca88 100644 --- a/zerver/actions/streams.py +++ b/zerver/actions/streams.py @@ -114,7 +114,7 @@ def send_user_remove_events_on_stream_deactivation( def do_deactivate_stream(stream: Stream, *, acting_user: Optional[UserProfile]) -> None: # If the stream is already deactivated, this is a no-op if stream.deactivated is True: - raise JsonableError(_("Stream is already deactivated")) + raise JsonableError(_("Channel is already deactivated")) # We want to mark all messages in the to-be-deactivated stream as # read for all users; otherwise they will pollute queries like @@ -238,10 +238,10 @@ def do_unarchive_stream( ) -> None: realm = stream.realm if not stream.deactivated: - raise JsonableError(_("Stream is not currently deactivated")) + raise JsonableError(_("Channel is not currently deactivated")) if Stream.objects.filter(realm=realm, name=new_name).exists(): raise JsonableError( - _("Stream named {channel_name} already exists").format(channel_name=new_name) + _("Channel named {channel_name} already exists").format(channel_name=new_name) ) assert stream.recipient_id is not None diff --git a/zerver/lib/email_mirror.py b/zerver/lib/email_mirror.py index b27e3b4cdf..999c6ea4e9 100644 --- a/zerver/lib/email_mirror.py +++ b/zerver/lib/email_mirror.py @@ -6,6 +6,7 @@ from email.message import EmailMessage from typing import Dict, List, Match, Optional, Tuple from django.conf import settings +from django.utils.translation import gettext as _ from typing_extensions import override from zerver.actions.message_send import ( @@ -205,7 +206,9 @@ def send_mm_reply_to_stream( message_content=body, ) except JsonableError as error: - error_message = f"Error sending message to stream {stream.name} via message notification email reply:\n{error.msg}" + error_message = _( + "Error sending message to channel {channel_name} via message notification email reply:\n{error_message}" + ).format(channel_name=stream.name, error_message=error.msg) internal_send_private_message( get_system_bot(settings.NOTIFICATION_BOT, user_profile.realm_id), user_profile, diff --git a/zerver/lib/streams.py b/zerver/lib/streams.py index 913e223dd9..8ed39edaca 100644 --- a/zerver/lib/streams.py +++ b/zerver/lib/streams.py @@ -239,21 +239,21 @@ def check_stream_access_based_on_stream_post_policy(sender: UserProfile, stream: if sender.is_realm_admin or is_cross_realm_bot_email(sender.delivery_email): pass elif stream.stream_post_policy == Stream.STREAM_POST_POLICY_ADMINS: - raise JsonableError(_("Only organization administrators can send to this stream.")) + raise JsonableError(_("Only organization administrators can send to this channel.")) elif ( stream.stream_post_policy == Stream.STREAM_POST_POLICY_MODERATORS and not sender.is_moderator ): raise JsonableError( - _("Only organization administrators and moderators can send to this stream.") + _("Only organization administrators and moderators can send to this channel.") ) elif stream.stream_post_policy != Stream.STREAM_POST_POLICY_EVERYONE and sender.is_guest: - raise JsonableError(_("Guests cannot send to this stream.")) + raise JsonableError(_("Guests cannot send to this channel.")) elif ( stream.stream_post_policy == Stream.STREAM_POST_POLICY_RESTRICT_NEW_MEMBERS and sender.is_provisional_member ): - raise JsonableError(_("New members cannot send to this stream.")) + raise JsonableError(_("New members cannot send to this channel.")) def access_stream_for_send_message( @@ -313,22 +313,25 @@ def access_stream_for_send_message( # All other cases are an error. raise JsonableError( - _("Not authorized to send to stream '{channel_name}'").format(channel_name=stream.name) + _("Not authorized to send to channel '{channel_name}'").format(channel_name=stream.name) ) def check_for_exactly_one_stream_arg(stream_id: Optional[int], stream: Optional[str]) -> None: if stream_id is None and stream is None: - raise JsonableError(_("Please supply 'stream'.")) + # Uses the same translated string as RequestVariableMissingError + # with the stream_id parameter, which is the more common use case. + error = _("Missing '{var_name}' argument").format(var_name="stream_id") + raise JsonableError(error) if stream_id is not None and stream is not None: - raise JsonableError(_("Please choose one: 'stream' or 'stream_id'.")) + raise JsonableError(_("Please supply only one channel parameter: name or ID.")) def check_stream_access_for_delete_or_update( user_profile: UserProfile, stream: Stream, sub: Optional[Subscription] = None ) -> None: - error = _("Invalid stream ID") + error = _("Invalid channel ID") if stream.realm_id != user_profile.realm_id: raise JsonableError(error) @@ -347,7 +350,7 @@ def access_stream_for_delete_or_update( try: stream = Stream.objects.get(id=stream_id) except Stream.DoesNotExist: - raise JsonableError(_("Invalid stream ID")) + raise JsonableError(_("Invalid channel ID")) try: sub = Subscription.objects.get( @@ -430,7 +433,7 @@ def access_stream_by_id( require_active: bool = True, allow_realm_admin: bool = False, ) -> Tuple[Stream, Optional[Subscription]]: - error = _("Invalid stream ID") + error = _("Invalid channel ID") try: stream = get_stream_by_id_in_realm(stream_id, user_profile.realm) except Stream.DoesNotExist: @@ -472,9 +475,7 @@ def check_stream_name_available(realm: Realm, name: str) -> None: check_stream_name(name) try: get_stream(name, realm) - raise JsonableError( - _("Stream name '{channel_name}' is already taken.").format(channel_name=name) - ) + raise JsonableError(_("Channel name already in use.")) except Stream.DoesNotExist: pass @@ -482,7 +483,7 @@ def check_stream_name_available(realm: Realm, name: str) -> None: def access_stream_by_name( user_profile: UserProfile, stream_name: str, allow_realm_admin: bool = False ) -> Tuple[Stream, Optional[Subscription]]: - error = _("Invalid stream name '{channel_name}'").format(channel_name=stream_name) + error = _("Invalid channel name '{channel_name}'").format(channel_name=stream_name) try: stream = get_realm_stream(stream_name, user_profile.realm_id) except Stream.DoesNotExist: @@ -498,7 +499,7 @@ def access_stream_by_name( def access_web_public_stream(stream_id: int, realm: Realm) -> Stream: - error = _("Invalid stream ID") + error = _("Invalid channel ID") try: stream = get_stream_by_id_in_realm(stream_id, realm) except Stream.DoesNotExist: @@ -602,7 +603,7 @@ def can_access_stream_history(user_profile: UserProfile, stream: Stream) -> bool if stream.is_history_public_to_subscribers(): # In this case, we check if the user is subscribed. - error = _("Invalid stream name '{channel_name}'").format(channel_name=stream.name) + error = _("Invalid channel name '{channel_name}'").format(channel_name=stream.name) try: access_stream_common(user_profile, stream, error) except JsonableError: @@ -747,11 +748,11 @@ def list_to_streams( if is_default_stream and not user_profile.is_realm_admin: raise JsonableError(_("Insufficient permission")) if invite_only and is_default_stream: - raise JsonableError(_("A default stream cannot be private.")) + raise JsonableError(_("A default channel cannot be private.")) if not autocreate: raise JsonableError( - _("Stream(s) ({channel_names}) do not exist").format( + _("Channel(s) ({channel_names}) do not exist").format( channel_names=", ".join( stream_dict["name"] for stream_dict in missing_stream_dicts ), @@ -760,7 +761,7 @@ def list_to_streams( if web_public_stream_requested: if not user_profile.realm.web_public_streams_enabled(): - raise JsonableError(_("Web-public streams are not enabled.")) + raise JsonableError(_("Web-public channels are not enabled.")) if not user_profile.can_create_web_public_streams(): # We set create_web_public_stream_policy to allow only organization owners # to create web-public streams, because of their sensitive nature. @@ -790,7 +791,9 @@ def access_default_stream_group_by_id(realm: Realm, group_id: int) -> DefaultStr return DefaultStreamGroup.objects.get(realm=realm, id=group_id) except DefaultStreamGroup.DoesNotExist: raise JsonableError( - _("Default stream group with id '{group_id}' does not exist.").format(group_id=group_id) + _("Default channel group with id '{group_id}' does not exist.").format( + group_id=group_id + ) ) diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index 29d2636e78..1c42b1199f 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -5139,7 +5139,7 @@ paths: - example: { "code": "BAD_REQUEST", - "msg": "Invalid stream name 'nonexistent'", + "msg": "Invalid channel name 'nonexistent'", "result": "error", } description: | @@ -6041,7 +6041,7 @@ paths: - example: { "code": "BAD_REQUEST", - "msg": "Private streams cannot be made default.", + "msg": "Private channels cannot be made default.", "result": "error", } description: | @@ -9469,7 +9469,7 @@ paths: - $ref: "#/components/schemas/CodedError" - example: { - "msg": "Unable to access stream (private_stream).", + "msg": "Unable to access channel (private).", "result": "error", "code": "BAD_REQUEST", } @@ -21281,7 +21281,7 @@ components: code: {} example: { - "msg": "Invalid stream ID", + "msg": "Invalid channel ID", "code": "BAD_REQUEST", "result": "error", } diff --git a/zerver/tests/test_bots.py b/zerver/tests/test_bots.py index fb89ac5a84..3ee1b3bf92 100644 --- a/zerver/tests/test_bots.py +++ b/zerver/tests/test_bots.py @@ -472,7 +472,7 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): "default_sending_stream": "Denmark", } result = self.client_post("/json/bots", bot_info) - self.assert_json_error(result, "Invalid stream name 'Denmark'") + self.assert_json_error(result, "Invalid channel name 'Denmark'") def test_add_bot_with_default_events_register_stream(self) -> None: bot_email = "hambot-bot@zulip.testserver" @@ -556,7 +556,7 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): "default_events_register_stream": "Denmark", } result = self.client_post("/json/bots", bot_info) - self.assert_json_error(result, "Invalid stream name 'Denmark'") + self.assert_json_error(result, "Invalid channel name 'Denmark'") def test_add_bot_with_default_all_public_streams(self) -> None: self.login("hamlet") @@ -1403,7 +1403,7 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): } email = "hambot-bot@zulip.testserver" result = self.client_patch(f"/json/bots/{self.get_bot_user(email).id}", bot_info) - self.assert_json_error(result, "Invalid stream name 'Denmark'") + self.assert_json_error(result, "Invalid channel name 'Denmark'") def test_patch_bot_to_stream_not_found(self) -> None: self.login("hamlet") @@ -1418,7 +1418,7 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): } email = "hambot-bot@zulip.testserver" result = self.client_patch(f"/json/bots/{self.get_bot_user(email).id}", bot_info) - self.assert_json_error(result, "Invalid stream name 'missing'") + self.assert_json_error(result, "Invalid channel name 'missing'") def test_patch_bot_events_register_stream(self) -> None: hamlet = self.example_user("hamlet") @@ -1453,7 +1453,7 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): self.subscribe(bot_user, stream_name) bot_info = dict(default_events_register_stream=stream_name) result = self.client_patch(url, bot_info) - self.assert_json_error_contains(result, "Invalid stream name") + self.assert_json_error_contains(result, "Invalid channel name") # Subscribing the owner allows us to patch the stream. self.subscribe(hamlet, stream_name) @@ -1520,7 +1520,7 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): } email = "hambot-bot@zulip.testserver" result = self.client_patch(f"/json/bots/{self.get_bot_user(email).id}", bot_info) - self.assert_json_error(result, "Invalid stream name 'Denmark'") + self.assert_json_error(result, "Invalid channel name 'Denmark'") def test_patch_bot_events_register_stream_none(self) -> None: self.login("hamlet") @@ -1560,7 +1560,7 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): } email = "hambot-bot@zulip.testserver" result = self.client_patch(f"/json/bots/{self.get_bot_user(email).id}", bot_info) - self.assert_json_error(result, "Invalid stream name 'missing'") + self.assert_json_error(result, "Invalid channel name 'missing'") def test_patch_bot_default_all_public_streams_true(self) -> None: self.login("hamlet") diff --git a/zerver/tests/test_drafts.py b/zerver/tests/test_drafts.py index b69b6a6780..2ddfb0a811 100644 --- a/zerver/tests/test_drafts.py +++ b/zerver/tests/test_drafts.py @@ -255,7 +255,7 @@ class DraftCreationTests(ZulipTestCase): "timestamp": 1595479019, } ] - self.create_and_check_drafts_for_error(draft_dicts, "Invalid stream ID") + self.create_and_check_drafts_for_error(draft_dicts, "Invalid channel ID") # When the stream itself does not exist: draft_dicts = [ @@ -267,7 +267,7 @@ class DraftCreationTests(ZulipTestCase): "timestamp": 1595479019, } ] - self.create_and_check_drafts_for_error(draft_dicts, "Invalid stream ID") + self.create_and_check_drafts_for_error(draft_dicts, "Invalid channel ID") def test_create_personal_message_draft_for_non_existing_user(self) -> None: draft_dicts = [ diff --git a/zerver/tests/test_email_mirror.py b/zerver/tests/test_email_mirror.py index b02f17bbd3..855836587a 100644 --- a/zerver/tests/test_email_mirror.py +++ b/zerver/tests/test_email_mirror.py @@ -1174,7 +1174,7 @@ class TestMissedMessageEmailMessages(ZulipTestCase): self.assertEqual( message.content, - "Error sending message to stream announce via message notification email reply:\nOnly organization administrators can send to this stream.", + "Error sending message to channel announce via message notification email reply:\nOnly organization administrators can send to this channel.", ) self.assertEqual( message.sender, diff --git a/zerver/tests/test_example.py b/zerver/tests/test_example.py index 850f44561b..2c2a1e6787 100644 --- a/zerver/tests/test_example.py +++ b/zerver/tests/test_example.py @@ -292,7 +292,7 @@ class TestStreamHelpers(ZulipTestCase): access_stream_for_send_message(cordelia, stream, forwarder_user_profile=None) # ...but Othello can't. - with self.assertRaisesRegex(JsonableError, "Not authorized to send to stream"): + with self.assertRaisesRegex(JsonableError, "Not authorized to send to channel"): access_stream_for_send_message(othello, stream, forwarder_user_profile=None) diff --git a/zerver/tests/test_message_flags.py b/zerver/tests/test_message_flags.py index b242262832..72f54ff304 100644 --- a/zerver/tests/test_message_flags.py +++ b/zerver/tests/test_message_flags.py @@ -590,7 +590,7 @@ class UnreadCountTests(ZulipTestCase): "stream_id": invalid_stream_id, }, ) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") def test_mark_all_topics_unread_with_invalid_stream_name(self) -> None: self.login("hamlet") @@ -602,7 +602,7 @@ class UnreadCountTests(ZulipTestCase): "topic_name": "whatever", }, ) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") def test_mark_all_in_stream_topic_read(self) -> None: self.login("hamlet") diff --git a/zerver/tests/test_message_move_stream.py b/zerver/tests/test_message_move_stream.py index 880bad4cfe..607b79f756 100644 --- a/zerver/tests/test_message_move_stream.py +++ b/zerver/tests/test_message_move_stream.py @@ -394,7 +394,7 @@ class MessageMoveStreamTest(ZulipTestCase): }, ) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") def test_move_message_realm_admin_cant_move_to_private_stream_without_subscription( self, @@ -414,7 +414,7 @@ class MessageMoveStreamTest(ZulipTestCase): }, ) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") def test_move_message_realm_admin_cant_move_from_private_stream_without_subscription( self, @@ -1000,7 +1000,7 @@ class MessageMoveStreamTest(ZulipTestCase): do_change_stream_post_policy( new_stream, Stream.STREAM_POST_POLICY_ADMINS, acting_user=user_profile ) - error_msg = "Only organization administrators can send to this stream." + error_msg = "Only organization administrators can send to this channel." check_move_message_to_stream(UserProfile.ROLE_MODERATOR, error_msg) check_move_message_to_stream(UserProfile.ROLE_REALM_ADMINISTRATOR) @@ -1012,7 +1012,7 @@ class MessageMoveStreamTest(ZulipTestCase): do_change_stream_post_policy( new_stream, Stream.STREAM_POST_POLICY_MODERATORS, acting_user=user_profile ) - error_msg = "Only organization administrators and moderators can send to this stream." + error_msg = "Only organization administrators and moderators can send to this channel." check_move_message_to_stream(UserProfile.ROLE_MEMBER, error_msg) check_move_message_to_stream(UserProfile.ROLE_MODERATOR) @@ -1024,7 +1024,7 @@ class MessageMoveStreamTest(ZulipTestCase): do_change_stream_post_policy( new_stream, Stream.STREAM_POST_POLICY_RESTRICT_NEW_MEMBERS, acting_user=user_profile ) - error_msg = "New members cannot send to this stream." + error_msg = "New members cannot send to this channel." do_set_realm_property( user_profile.realm, "waiting_period_threshold", 100000, acting_user=None diff --git a/zerver/tests/test_message_send.py b/zerver/tests/test_message_send.py index 24ace18241..0ba9464342 100644 --- a/zerver/tests/test_message_send.py +++ b/zerver/tests/test_message_send.py @@ -268,7 +268,7 @@ class MessagePOSTTest(ZulipTestCase): self._send_and_verify_message( non_admin_profile, stream_name, - "Only organization administrators can send to this stream.", + "Only organization administrators can send to this channel.", ) non_admin_owned_bot = self.create_test_bot( short_name="whatever2", @@ -278,7 +278,7 @@ class MessagePOSTTest(ZulipTestCase): self._send_and_verify_message( non_admin_owned_bot, stream_name, - "Only organization administrators can send to this stream.", + "Only organization administrators can send to this channel.", ) moderator_profile = self.example_user("shiva") @@ -288,7 +288,7 @@ class MessagePOSTTest(ZulipTestCase): self._send_and_verify_message( moderator_profile, stream_name, - "Only organization administrators can send to this stream.", + "Only organization administrators can send to this channel.", ) moderator_owned_bot = self.create_test_bot( short_name="whatever3", @@ -298,7 +298,7 @@ class MessagePOSTTest(ZulipTestCase): self._send_and_verify_message( moderator_owned_bot, stream_name, - "Only organization administrators can send to this stream.", + "Only organization administrators can send to this channel.", ) # Bots without owner (except cross realm bot) cannot send to announcement only streams @@ -313,7 +313,7 @@ class MessagePOSTTest(ZulipTestCase): self._send_and_verify_message( bot_without_owner, stream_name, - "Only organization administrators can send to this stream.", + "Only organization administrators can send to this channel.", ) # Cross realm bots should be allowed @@ -326,7 +326,7 @@ class MessagePOSTTest(ZulipTestCase): guest_profile = self.example_user("polonius") # Guests cannot send to non-STREAM_POST_POLICY_EVERYONE streams self._send_and_verify_message( - guest_profile, stream_name, "Only organization administrators can send to this stream." + guest_profile, stream_name, "Only organization administrators can send to this channel." ) def test_sending_message_as_stream_post_policy_moderators(self) -> None: @@ -370,7 +370,7 @@ class MessagePOSTTest(ZulipTestCase): self._send_and_verify_message( non_admin_profile, stream_name, - "Only organization administrators and moderators can send to this stream.", + "Only organization administrators and moderators can send to this channel.", ) non_admin_owned_bot = self.create_test_bot( short_name="whatever3", @@ -380,7 +380,7 @@ class MessagePOSTTest(ZulipTestCase): self._send_and_verify_message( non_admin_owned_bot, stream_name, - "Only organization administrators and moderators can send to this stream.", + "Only organization administrators and moderators can send to this channel.", ) # Bots without owner (except cross realm bot) cannot send to STREAM_POST_POLICY_MODERATORS streams. @@ -395,7 +395,7 @@ class MessagePOSTTest(ZulipTestCase): self._send_and_verify_message( bot_without_owner, stream_name, - "Only organization administrators and moderators can send to this stream.", + "Only organization administrators and moderators can send to this channel.", ) # System bots should be allowed @@ -410,7 +410,7 @@ class MessagePOSTTest(ZulipTestCase): self._send_and_verify_message( guest_profile, stream_name, - "Only organization administrators and moderators can send to this stream.", + "Only organization administrators and moderators can send to this channel.", ) def test_sending_message_as_stream_post_policy_restrict_new_members(self) -> None: @@ -453,7 +453,7 @@ class MessagePOSTTest(ZulipTestCase): # Non admins and their owned bots can send to STREAM_POST_POLICY_RESTRICT_NEW_MEMBERS streams, # if the user is not a new member self._send_and_verify_message( - non_admin_profile, stream_name, "New members cannot send to this stream." + non_admin_profile, stream_name, "New members cannot send to this channel." ) non_admin_owned_bot = self.create_test_bot( short_name="whatever2", @@ -461,7 +461,7 @@ class MessagePOSTTest(ZulipTestCase): user_profile=non_admin_profile, ) self._send_and_verify_message( - non_admin_owned_bot, stream_name, "New members cannot send to this stream." + non_admin_owned_bot, stream_name, "New members cannot send to this channel." ) non_admin_profile.date_joined = timezone_now() - timedelta(days=11) @@ -485,7 +485,7 @@ class MessagePOSTTest(ZulipTestCase): acting_user=None, ) self._send_and_verify_message( - bot_without_owner, stream_name, "New members cannot send to this stream." + bot_without_owner, stream_name, "New members cannot send to this channel." ) moderator_profile = self.example_user("shiva") @@ -516,7 +516,7 @@ class MessagePOSTTest(ZulipTestCase): guest_profile = self.example_user("polonius") # Guests cannot send to non-STREAM_POST_POLICY_EVERYONE streams self._send_and_verify_message( - guest_profile, stream_name, "Guests cannot send to this stream." + guest_profile, stream_name, "Guests cannot send to this channel." ) def test_api_message_with_default_to(self) -> None: @@ -1447,7 +1447,7 @@ class MessagePOSTTest(ZulipTestCase): # Guest user can't send message to unsubscribed public streams result = self.api_post(sender, "/api/v1/messages", payload) - self.assert_json_error(result, "Not authorized to send to stream 'public stream'") + self.assert_json_error(result, "Not authorized to send to channel 'public stream'") self.subscribe(sender, stream_name) # Guest user can send message to subscribed public streams diff --git a/zerver/tests/test_message_topics.py b/zerver/tests/test_message_topics.py index 0d58af24bc..b8c36896e0 100644 --- a/zerver/tests/test_message_topics.py +++ b/zerver/tests/test_message_topics.py @@ -160,7 +160,7 @@ class TopicHistoryTest(ZulipTestCase): # non-sensible stream id endpoint = "/json/users/me/9999999999/topics" result = self.client_get(endpoint, {}) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") # out of realm bad_stream = self.make_stream( @@ -169,7 +169,7 @@ class TopicHistoryTest(ZulipTestCase): ) endpoint = f"/json/users/me/{bad_stream.id}/topics" result = self.client_get(endpoint, {}) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") # private stream to which I am not subscribed private_stream = self.make_stream( @@ -178,7 +178,7 @@ class TopicHistoryTest(ZulipTestCase): ) endpoint = f"/json/users/me/{private_stream.id}/topics" result = self.client_get(endpoint, {}) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") def test_get_topics_web_public_stream_web_public_request(self) -> None: iago = self.example_user("iago") @@ -204,13 +204,13 @@ class TopicHistoryTest(ZulipTestCase): stream = get_stream("Verona", self.example_user("iago").realm) endpoint = f"/json/users/me/{stream.id}/topics" result = self.client_get(endpoint) - self.assert_json_error(result, "Invalid stream ID", 400) + self.assert_json_error(result, "Invalid channel ID", 400) def test_get_topics_non_existent_stream_web_public_request(self) -> None: non_existent_stream_id = 10000000000000000000000 endpoint = f"/json/users/me/{non_existent_stream_id}/topics" result = self.client_get(endpoint) - self.assert_json_error(result, "Invalid stream ID", 400) + self.assert_json_error(result, "Invalid channel ID", 400) class TopicDeleteTest(ZulipTestCase): diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py index 8f3e31b594..9300a70689 100644 --- a/zerver/tests/test_realm.py +++ b/zerver/tests/test_realm.py @@ -520,7 +520,7 @@ class RealmTest(ZulipTestCase): new_stream_announcements_stream_id=orjson.dumps(invalid_notif_stream_id).decode() ) result = self.client_patch("/json/realm", req) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") realm = get_realm("zulip") assert realm.new_stream_announcements_stream is not None self.assertNotEqual(realm.new_stream_announcements_stream.id, invalid_notif_stream_id) @@ -605,7 +605,7 @@ class RealmTest(ZulipTestCase): ).decode() ) result = self.client_patch("/json/realm", req) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") realm = get_realm("zulip") assert realm.signup_announcements_stream is not None self.assertNotEqual( @@ -679,7 +679,7 @@ class RealmTest(ZulipTestCase): ).decode() ) result = self.client_patch("/json/realm", req) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") realm = get_realm("zulip") assert realm.zulip_update_announcements_stream is not None self.assertNotEqual( diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py index fc36a7b775..3a562fc707 100644 --- a/zerver/tests/test_subs.py +++ b/zerver/tests/test_subs.py @@ -425,7 +425,7 @@ class TestCreateStreams(ZulipTestCase): result = self.api_post( user_profile, "/api/v1/users/me/subscriptions", post_data, subdomain="zulip" ) - self.assert_json_error(result, "A default stream cannot be private.") + self.assert_json_error(result, "A default channel cannot be private.") def test_history_public_to_subscribers_zephyr_realm(self) -> None: realm = get_realm("zephyr") @@ -654,7 +654,7 @@ class StreamAdminTest(ZulipTestCase): } stream_id = get_stream("private_stream_1", user_profile.realm).id result = self.client_patch(f"/json/streams/{stream_id}", params) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") stream = self.subscribe(user_profile, "private_stream_1") self.assertFalse(stream.is_in_zephyr_realm) @@ -772,7 +772,7 @@ class StreamAdminTest(ZulipTestCase): "is_private": orjson.dumps(True).decode(), } result = self.client_patch(f"/json/streams/{default_stream.id}", params) - self.assert_json_error(result, "A default stream cannot be private.") + self.assert_json_error(result, "A default channel cannot be private.") self.assertFalse(default_stream.invite_only) do_change_user_role(user_profile, UserProfile.ROLE_MEMBER, acting_user=None) @@ -808,7 +808,7 @@ class StreamAdminTest(ZulipTestCase): with self.settings(WEB_PUBLIC_STREAMS_ENABLED=False): self.assertFalse(user_profile.can_create_web_public_streams()) self.assertFalse(owner.can_create_web_public_streams()) - with self.assertRaisesRegex(JsonableError, "Web-public streams are not enabled."): + with self.assertRaisesRegex(JsonableError, "Web-public channels are not enabled."): list_to_streams( streams_raw, owner, @@ -981,7 +981,7 @@ class StreamAdminTest(ZulipTestCase): do_change_user_role(user_profile, UserProfile.ROLE_REALM_OWNER, acting_user=None) with self.settings(WEB_PUBLIC_STREAMS_ENABLED=False): result = self.client_patch(f"/json/streams/{stream_id}", params) - self.assert_json_error(result, "Web-public streams are not enabled.") + self.assert_json_error(result, "Web-public channels are not enabled.") bad_params = { "is_web_public": orjson.dumps(True).decode(), @@ -1120,7 +1120,7 @@ class StreamAdminTest(ZulipTestCase): "is_private": orjson.dumps(True).decode(), } result = self.client_patch(f"/json/streams/{stream_id}", params) - self.assert_json_error(result, "A default stream cannot be private.") + self.assert_json_error(result, "A default channel cannot be private.") stream.refresh_from_db() self.assertFalse(stream.invite_only) @@ -1142,7 +1142,7 @@ class StreamAdminTest(ZulipTestCase): "is_private": orjson.dumps(True).decode(), } result = self.client_patch(f"/json/streams/{stream_2_id}", bad_params) - self.assert_json_error(result, "A default stream cannot be private.") + self.assert_json_error(result, "A default channel cannot be private.") stream.refresh_from_db() self.assertFalse(stream_2.invite_only) self.assertFalse(stream_2_id in get_default_stream_ids_for_realm(realm.id)) @@ -1154,7 +1154,7 @@ class StreamAdminTest(ZulipTestCase): "is_default_stream": orjson.dumps(True).decode(), } result = self.client_patch(f"/json/streams/{private_stream_id}", params) - self.assert_json_error(result, "A default stream cannot be private.") + self.assert_json_error(result, "A default channel cannot be private.") self.assertFalse(private_stream_id in get_default_stream_ids_for_realm(realm.id)) params = { @@ -1472,14 +1472,14 @@ class StreamAdminTest(ZulipTestCase): def test_unarchive_stream_active_stream(self) -> None: stream = self.make_stream("new_stream") - with self.assertRaisesRegex(JsonableError, "Stream is not currently deactivated"): + with self.assertRaisesRegex(JsonableError, "Channel is not currently deactivated"): do_unarchive_stream(stream, new_name="new_stream", acting_user=None) def test_unarchive_stream_existing_name(self) -> None: stream = self.make_stream("new_stream") self.make_stream("existing") do_deactivate_stream(stream, acting_user=None) - with self.assertRaisesRegex(JsonableError, "Stream named existing already exists"): + with self.assertRaisesRegex(JsonableError, "Channel named existing already exists"): do_unarchive_stream(stream, new_name="existing", acting_user=None) def test_unarchive_stream(self) -> None: @@ -1558,7 +1558,7 @@ class StreamAdminTest(ZulipTestCase): do_change_user_role(user_profile, UserProfile.ROLE_REALM_ADMINISTRATOR, acting_user=None) result = self.client_delete("/json/streams/999999999") - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") def test_deactivate_stream_backend_requires_admin(self) -> None: user_profile = self.example_user("hamlet") @@ -1621,11 +1621,11 @@ class StreamAdminTest(ZulipTestCase): do_change_user_role(user_profile, UserProfile.ROLE_REALM_ADMINISTRATOR, acting_user=None) result = self.client_patch(f"/json/streams/{stream.id}", {"new_name": "stream_name1"}) - self.assert_json_error(result, "Stream already has that name!") + self.assert_json_error(result, "Channel already has that name.") result = self.client_patch(f"/json/streams/{stream.id}", {"new_name": "Denmark"}) - self.assert_json_error(result, "Stream name 'Denmark' is already taken.") + self.assert_json_error(result, "Channel name already in use.") result = self.client_patch(f"/json/streams/{stream.id}", {"new_name": "denmark "}) - self.assert_json_error(result, "Stream name 'denmark' is already taken.") + self.assert_json_error(result, "Channel name already in use.") # Do a rename that is case-only--this should succeed. result = self.client_patch(f"/json/streams/{stream.id}", {"new_name": "sTREAm_name1"}) @@ -1784,7 +1784,7 @@ class StreamAdminTest(ZulipTestCase): "is_private": orjson.dumps(True).decode(), }, ) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") def test_non_admin_cannot_access_unsub_private_stream(self) -> None: iago = self.example_user("iago") @@ -1802,13 +1802,13 @@ class StreamAdminTest(ZulipTestCase): stream_id = get_stream("private_stream_1", hamlet.realm).id result = self.client_patch(f"/json/streams/{stream_id}", {"new_name": "private_stream_2"}) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") result = self.client_patch( f"/json/streams/{stream_id}", {"description": "new description"}, ) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") result = self.client_patch( f"/json/streams/{stream_id}", @@ -1816,10 +1816,10 @@ class StreamAdminTest(ZulipTestCase): "is_private": orjson.dumps(True).decode(), }, ) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") result = self.client_delete(f"/json/streams/{stream_id}") - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") def test_change_stream_description(self) -> None: user_profile = self.example_user("iago") @@ -2332,7 +2332,7 @@ class StreamAdminTest(ZulipTestCase): f"/json/streams/{stream.id}", {"can_remove_subscribers_group": orjson.dumps(moderators_system_group.id).decode()}, ) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") self.subscribe(user_profile, "stream_name2") result = self.client_patch( @@ -2489,12 +2489,12 @@ class StreamAdminTest(ZulipTestCase): "/json/users/me/subscriptions", {"subscriptions": orjson.dumps([{"name": deactivated_stream_name}]).decode()}, ) - self.assert_json_error(result, f"Unable to access stream ({deactivated_stream_name}).") + self.assert_json_error(result, f"Unable to access channel ({deactivated_stream_name}).") # You cannot re-archive the stream with self.capture_send_event_calls(expected_num_events=0) as events: result = self.client_delete("/json/streams/" + str(stream_id)) - self.assert_json_error(result, "Stream is already deactivated") + self.assert_json_error(result, "Channel is already deactivated") def test_you_must_be_realm_admin(self) -> None: """ @@ -2507,13 +2507,13 @@ class StreamAdminTest(ZulipTestCase): stream = self.make_stream("other_realm_stream", realm=other_realm) result = self.client_delete("/json/streams/" + str(stream.id)) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") # Even becoming a realm admin doesn't help us for an out-of-realm # stream. do_change_user_role(user_profile, UserProfile.ROLE_REALM_ADMINISTRATOR, acting_user=None) result = self.client_delete("/json/streams/" + str(stream.id)) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") def test_delete_public_stream(self) -> None: """ @@ -2964,12 +2964,12 @@ class DefaultStreamTest(ZulipTestCase): stream = self.make_stream(stream_name, invite_only=True) self.subscribe(self.example_user("iago"), stream_name) result = self.client_post("/json/default_streams", dict(stream_id=stream.id)) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") # Test admin can't add subscribed private stream also. self.subscribe(user_profile, stream_name) result = self.client_post("/json/default_streams", dict(stream_id=stream.id)) - self.assert_json_error(result, "Private streams cannot be made default.") + self.assert_json_error(result, "Private channels cannot be made default.") def test_guest_user_access_to_streams(self) -> None: user_profile = self.example_user("polonius") @@ -3145,7 +3145,7 @@ class DefaultStreamGroupTest(ZulipTestCase): "/json/default_stream_groups/12345/streams", {"op": "add", "stream_names": orjson.dumps(new_stream_names).decode()}, ) - self.assert_json_error(result, "Default stream group with id '12345' does not exist.") + self.assert_json_error(result, "Default channel group with id '12345' does not exist.") result = self.client_patch(f"/json/default_stream_groups/{group_id}/streams", {"op": "add"}) self.assert_json_error(result, "Missing 'stream_names' argument") @@ -3183,13 +3183,13 @@ class DefaultStreamGroupTest(ZulipTestCase): "/json/default_stream_groups/12345/streams", {"op": "remove", "stream_names": orjson.dumps(new_stream_names).decode()}, ) - self.assert_json_error(result, "Default stream group with id '12345' does not exist.") + self.assert_json_error(result, "Default channel group with id '12345' does not exist.") result = self.client_patch( f"/json/default_stream_groups/{group_id}/streams", {"op": "remove", "stream_names": orjson.dumps(["random stream name"]).decode()}, ) - self.assert_json_error(result, "Invalid stream name 'random stream name'") + self.assert_json_error(result, "Invalid channel name 'random stream name'") streams.remove(new_streams[0]) result = self.client_patch( @@ -3220,7 +3220,7 @@ class DefaultStreamGroupTest(ZulipTestCase): "/json/default_stream_groups/12345", {"new_description": new_description}, ) - self.assert_json_error(result, "Default stream group with id '12345' does not exist.") + self.assert_json_error(result, "Default channel group with id '12345' does not exist.") result = self.client_patch( f"/json/default_stream_groups/{group_id}", @@ -3266,7 +3266,9 @@ class DefaultStreamGroupTest(ZulipTestCase): self.assert_length(default_stream_groups, 0) result = self.client_delete(f"/json/default_stream_groups/{group_id}") - self.assert_json_error(result, f"Default stream group with id '{group_id}' does not exist.") + self.assert_json_error( + result, f"Default channel group with id '{group_id}' does not exist." + ) def test_invalid_default_stream_group_name(self) -> None: self.login("iago") @@ -3420,7 +3422,7 @@ class SubscriptionPropertiesTest(ZulipTestCase): }, ) self.assert_json_error( - result, "Not subscribed to stream id {}".format(not_subbed[0]["stream_id"]) + result, "Not subscribed to channel ID {}".format(not_subbed[0]["stream_id"]) ) def test_set_color_missing_color(self) -> None: @@ -3720,7 +3722,7 @@ class SubscriptionPropertiesTest(ZulipTestCase): ).decode() }, ) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") def test_set_invalid_property(self) -> None: """ @@ -3858,7 +3860,7 @@ class SubscriptionRestApiTest(ZulipTestCase): "/api/v1/users/me/subscriptions/121", {"property": "is_muted", "value": "somevalue"}, ) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") def test_bad_add_parameters(self) -> None: user = self.example_user("hamlet") @@ -5081,7 +5083,7 @@ class SubscriptionAPITest(ZulipTestCase): ) self.assert_json_error( result, - "You can only invite other Zephyr mirroring users to private streams.", + "You can only invite other Zephyr mirroring users to private channels.", status_code=400, ) @@ -5304,7 +5306,7 @@ class SubscriptionAPITest(ZulipTestCase): "/json/users/me/subscriptions", {"subscriptions": orjson.dumps(streams_to_remove).decode()}, ) - self.assert_json_error(result, f"Stream(s) ({random_streams[0]}) do not exist") + self.assert_json_error(result, f"Channel(s) ({random_streams[0]}) do not exist") def get_subscription(self, user_profile: UserProfile, stream_name: str) -> Subscription: stream = get_stream(stream_name, self.test_realm) @@ -5675,14 +5677,14 @@ class GetStreamsTest(ZulipTestCase): self.assertEqual(json["stream"]["stream_id"], denmark_stream.id) result = self.client_get("/json/streams/9999") - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") private_stream = self.make_stream("private_stream", invite_only=True) self.subscribe(self.example_user("cordelia"), "private_stream") # Non-admins cannot access unsubscribed private streams. result = self.client_get(f"/json/streams/{private_stream.id}") - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") self.login("iago") result = self.client_get(f"/json/streams/{private_stream.id}") @@ -5712,7 +5714,7 @@ class GetStreamsTest(ZulipTestCase): self.login("polonius") result = self.client_get(f"/json/streams/{denmark_stream.id}/email_address") - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") self.subscribe(polonius, "Denmark") result = self.client_get(f"/json/streams/{denmark_stream.id}/email_address") @@ -5733,7 +5735,7 @@ class GetStreamsTest(ZulipTestCase): self.unsubscribe(hamlet, "Denmark") result = self.client_get(f"/json/streams/{denmark_stream.id}/email_address") - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") self.login("iago") result = self.client_get(f"/json/streams/{denmark_stream.id}/email_address") @@ -5742,7 +5744,7 @@ class GetStreamsTest(ZulipTestCase): self.unsubscribe(iago, "Denmark") result = self.client_get(f"/json/streams/{denmark_stream.id}/email_address") - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") class StreamIdTest(ZulipTestCase): @@ -5758,7 +5760,7 @@ class StreamIdTest(ZulipTestCase): user = self.example_user("hamlet") self.login_user(user) result = self.client_get("/json/get_stream_id", {"stream": "wrongname"}) - self.assert_json_error(result, "Invalid stream name 'wrongname'") + self.assert_json_error(result, "Invalid channel name 'wrongname'") class InviteOnlyStreamTest(ZulipTestCase): @@ -5816,7 +5818,7 @@ class InviteOnlyStreamTest(ZulipTestCase): # Subscribing oneself to an invite-only stream is not allowed self.login_user(othello) result = self.common_subscribe_to_streams(othello, [stream_name], allow_fail=True) - self.assert_json_error(result, "Unable to access stream (Saxony).") + self.assert_json_error(result, "Unable to access channel (Saxony).") # authorization_errors_fatal=False works self.login_user(othello) @@ -6334,7 +6336,7 @@ class GetSubscribersTest(ZulipTestCase): # Verify another user can't get the data. self.login("cordelia") result = self.client_get(f"/json/streams/{stream_id}/members") - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") # But an organization administrator can self.login("iago") @@ -6347,7 +6349,7 @@ class GetSubscribersTest(ZulipTestCase): """ stream_id = 99999999 result = self.client_get(f"/json/streams/{stream_id}/members") - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") def test_json_get_subscribers(self) -> None: """ @@ -6402,7 +6404,7 @@ class GetSubscribersTest(ZulipTestCase): # Try to fetch the subscriber list as a non-member & non-realm-admin-user. stream_id = get_stream(stream_name, user_profile.realm).id result = self.make_subscriber_request(stream_id, user=user_profile) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") # Try to fetch the subscriber list as a non-member & realm-admin-user. self.login("iago") @@ -6425,9 +6427,9 @@ class AccessStreamTest(ZulipTestCase): othello = self.example_user("othello") # Nobody can access a stream that doesn't exist - with self.assertRaisesRegex(JsonableError, "Invalid stream ID"): + with self.assertRaisesRegex(JsonableError, "Invalid channel ID"): access_stream_by_id(hamlet, 501232) - with self.assertRaisesRegex(JsonableError, "Invalid stream name 'invalid stream'"): + with self.assertRaisesRegex(JsonableError, "Invalid channel name 'invalid stream'"): access_stream_by_name(hamlet, "invalid stream") # Hamlet can access the private stream @@ -6440,9 +6442,9 @@ class AccessStreamTest(ZulipTestCase): self.assertEqual(sub_ret, sub_ret2) # Othello cannot access the private stream - with self.assertRaisesRegex(JsonableError, "Invalid stream ID"): + with self.assertRaisesRegex(JsonableError, "Invalid channel ID"): access_stream_by_id(othello, stream.id) - with self.assertRaisesRegex(JsonableError, "Invalid stream name 'new_private_stream'"): + with self.assertRaisesRegex(JsonableError, "Invalid channel name 'new_private_stream'"): access_stream_by_name(othello, stream.name) # Both Othello and Hamlet can access a public stream that only @@ -6459,19 +6461,19 @@ class AccessStreamTest(ZulipTestCase): mit_realm = get_realm("zephyr") mit_stream = ensure_stream(mit_realm, "mit_stream", invite_only=False, acting_user=None) sipbtest = self.mit_user("sipbtest") - with self.assertRaisesRegex(JsonableError, "Invalid stream ID"): + with self.assertRaisesRegex(JsonableError, "Invalid channel ID"): access_stream_by_id(hamlet, mit_stream.id) - with self.assertRaisesRegex(JsonableError, "Invalid stream name 'mit_stream'"): + with self.assertRaisesRegex(JsonableError, "Invalid channel name 'mit_stream'"): access_stream_by_name(hamlet, mit_stream.name) - with self.assertRaisesRegex(JsonableError, "Invalid stream ID"): + with self.assertRaisesRegex(JsonableError, "Invalid channel ID"): access_stream_by_id(sipbtest, stream.id) - with self.assertRaisesRegex(JsonableError, "Invalid stream name 'new_private_stream'"): + with self.assertRaisesRegex(JsonableError, "Invalid channel name 'new_private_stream'"): access_stream_by_name(sipbtest, stream.name) # MIT realm users cannot access even public streams in their realm - with self.assertRaisesRegex(JsonableError, "Invalid stream ID"): + with self.assertRaisesRegex(JsonableError, "Invalid channel ID"): access_stream_by_id(sipbtest, mit_stream.id) - with self.assertRaisesRegex(JsonableError, "Invalid stream name 'mit_stream'"): + with self.assertRaisesRegex(JsonableError, "Invalid channel name 'mit_stream'"): access_stream_by_name(sipbtest, mit_stream.name) # But they can access streams they are subscribed to @@ -6486,7 +6488,7 @@ class AccessStreamTest(ZulipTestCase): stream = self.make_stream(stream_name, guest_user_profile.realm, invite_only=False) # Guest user don't have access to unsubscribed public streams - with self.assertRaisesRegex(JsonableError, "Invalid stream ID"): + with self.assertRaisesRegex(JsonableError, "Invalid channel ID"): access_stream_by_id(guest_user_profile, stream.id) # Guest user have access to subscribed public streams @@ -6499,7 +6501,7 @@ class AccessStreamTest(ZulipTestCase): stream_name = "private_stream_1" stream = self.make_stream(stream_name, guest_user_profile.realm, invite_only=True) # Obviously, a guest user doesn't have access to unsubscribed private streams either - with self.assertRaisesRegex(JsonableError, "Invalid stream ID"): + with self.assertRaisesRegex(JsonableError, "Invalid channel ID"): access_stream_by_id(guest_user_profile, stream.id) # Guest user have access to subscribed private streams diff --git a/zerver/tests/test_typing.py b/zerver/tests/test_typing.py index 21d0021cd4..9e94e226c7 100644 --- a/zerver/tests/test_typing.py +++ b/zerver/tests/test_typing.py @@ -145,7 +145,7 @@ class TypingValidateStreamIdTopicArgumentsTest(ZulipTestCase): "topic": topic_name, }, ) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") class TypingHappyPathTestDirectMessages(ZulipTestCase): diff --git a/zerver/tests/test_user_topics.py b/zerver/tests/test_user_topics.py index bf5ab4c697..08f3144f42 100644 --- a/zerver/tests/test_user_topics.py +++ b/zerver/tests/test_user_topics.py @@ -190,15 +190,15 @@ class MutedTopicsTestsDeprecated(ZulipTestCase): data = {"stream_id": 999999999, "topic": "Verona3", "op": "add"} result = self.api_patch(user, url, data) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") data = {"topic": "Verona3", "op": "add"} result = self.api_patch(user, url, data) - self.assert_json_error(result, "Please supply 'stream'.") + self.assert_json_error(result, "Missing 'stream_id' argument") data = {"stream": stream.name, "stream_id": stream.id, "topic": "Verona3", "op": "add"} result = self.api_patch(user, url, data) - self.assert_json_error(result, "Please choose one: 'stream' or 'stream_id'.") + self.assert_json_error(result, "Please supply only one channel parameter: name or ID.") data = {"stream_id": stream.id, "topic": "a" * (MAX_TOPIC_NAME_LENGTH + 1), "op": "add"} result = self.api_patch(user, url, data) @@ -234,11 +234,11 @@ class MutedTopicsTestsDeprecated(ZulipTestCase): data = {"topic": "Verona3", "op": "remove"} result = self.api_patch(user, url, data) - self.assert_json_error(result, "Please supply 'stream'.") + self.assert_json_error(result, "Missing 'stream_id' argument") data = {"stream": stream.name, "stream_id": stream.id, "topic": "Verona3", "op": "remove"} result = self.api_patch(user, url, data) - self.assert_json_error(result, "Please choose one: 'stream' or 'stream_id'.") + self.assert_json_error(result, "Please supply only one channel parameter: name or ID.") data = {"stream_id": stream.id, "topic": "a" * (MAX_TOPIC_NAME_LENGTH + 1), "op": "remove"} result = self.api_patch(user, url, data) @@ -447,7 +447,7 @@ class MutedTopicsTests(ZulipTestCase): "visibility_policy": UserTopic.VisibilityPolicy.MUTED, } result = self.api_post(user, url, data) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") stream = get_stream("Verona", user.realm) data = { @@ -472,7 +472,7 @@ class MutedTopicsTests(ZulipTestCase): } result = self.api_post(user, url, data) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") stream = get_stream("Verona", user.realm) data = { @@ -663,7 +663,7 @@ class UnmutedTopicsTests(ZulipTestCase): } result = self.api_post(user, url, data) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") def test_unmuted_topic_remove_invalid(self) -> None: user = self.example_user("hamlet") @@ -677,7 +677,7 @@ class UnmutedTopicsTests(ZulipTestCase): } result = self.api_post(user, url, data) - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") class AutomaticallyFollowTopicsTests(ZulipTestCase): diff --git a/zerver/tests/test_users.py b/zerver/tests/test_users.py index ac29064afb..def5bca463 100644 --- a/zerver/tests/test_users.py +++ b/zerver/tests/test_users.py @@ -1492,7 +1492,7 @@ class UserProfileTest(ZulipTestCase): # Invalid stream ID. result = self.client_get(f"/json/users/{iago.id}/subscriptions/25") - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") result = orjson.loads( self.client_get(f"/json/users/{iago.id}/subscriptions/{stream.id}").content @@ -1541,7 +1541,7 @@ class UserProfileTest(ZulipTestCase): # Unsubscribed non-admins cannot check subscription status in a private stream. self.login("shiva") result = self.client_get(f"/json/users/{iago.id}/subscriptions/{stream.id}") - self.assert_json_error(result, "Invalid stream ID") + self.assert_json_error(result, "Invalid channel ID") # Subscribed non-admins can check subscription status in a private stream self.subscribe(self.example_user("shiva"), stream.name) diff --git a/zerver/views/streams.py b/zerver/views/streams.py index 3db4590e94..b45ac7583c 100644 --- a/zerver/views/streams.py +++ b/zerver/views/streams.py @@ -130,7 +130,7 @@ def add_default_stream( ) -> HttpResponse: (stream, sub) = access_stream_by_id(user_profile, stream_id) if stream.invite_only: - raise JsonableError(_("Private streams cannot be made default.")) + raise JsonableError(_("Private channels cannot be made default.")) do_add_default_stream(stream) return json_success(request) @@ -296,7 +296,7 @@ def update_stream_backend( # Ensure that a stream cannot be both a default stream for new users and private if proposed_is_private and proposed_is_default_stream: - raise JsonableError(_("A default stream cannot be private.")) + raise JsonableError(_("A default channel cannot be private.")) if is_private is not None: # We require even realm administrators to be actually @@ -309,7 +309,7 @@ def update_stream_backend( # web-public, we don't use an "is not None" check. if is_web_public: if not user_profile.realm.web_public_streams_enabled(): - raise JsonableError(_("Web-public streams are not enabled.")) + raise JsonableError(_("Web-public channels are not enabled.")) if not user_profile.can_create_web_public_streams(): raise JsonableError(_("Insufficient permission")) @@ -351,7 +351,7 @@ def update_stream_backend( if new_name is not None: new_name = new_name.strip() if stream.name == new_name: - raise JsonableError(_("Stream already has that name!")) + raise JsonableError(_("Channel already has that name.")) if stream.name.lower() != new_name.lower(): # Check that the stream name is available (unless we are # are only changing the casing of the stream name). @@ -380,7 +380,7 @@ def update_stream_backend( ] != getattr(stream, setting_group_id_name): if sub is None and stream.invite_only: # Admins cannot change this setting for unsubscribed private streams. - raise JsonableError(_("Invalid stream ID")) + raise JsonableError(_("Invalid channel ID")) user_group_id = request_settings_dict[setting_group_id_name] user_group = access_user_group_for_setting( @@ -636,7 +636,7 @@ def add_subscriptions_backend( ) if len(unauthorized_streams) > 0 and authorization_errors_fatal: raise JsonableError( - _("Unable to access stream ({channel_name}).").format( + _("Unable to access channel ({channel_name}).").format( channel_name=unauthorized_streams[0].name, ) ) @@ -649,7 +649,7 @@ def add_subscriptions_backend( and not all(stream.invite_only for stream in streams) ): raise JsonableError( - _("You can only invite other Zephyr mirroring users to private streams.") + _("You can only invite other Zephyr mirroring users to private channels.") ) if is_default_stream: @@ -1016,7 +1016,7 @@ def update_subscription_properties_backend( (stream, sub) = access_stream_by_id(user_profile, stream_id) if sub is None: raise JsonableError( - _("Not subscribed to stream id {channel_id}").format(channel_id=stream_id) + _("Not subscribed to channel ID {channel_id}").format(channel_id=stream_id) ) try: diff --git a/zerver/views/user_topics.py b/zerver/views/user_topics.py index 43d68d38f8..4b39dd45a5 100644 --- a/zerver/views/user_topics.py +++ b/zerver/views/user_topics.py @@ -99,7 +99,7 @@ def update_user_topic( visibility_policy: int = REQ(json_validator=check_int_in(UserTopic.VisibilityPolicy.values)), ) -> HttpResponse: if visibility_policy == UserTopic.VisibilityPolicy.INHERIT: - error = _("Invalid stream ID") + error = _("Invalid channel ID") stream = access_stream_to_remove_visibility_policy_by_id(user_profile, stream_id, error) else: (stream, sub) = access_stream_by_id(user_profile, stream_id)