mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
streams: Capitalize "ID" in invalid stream errors in API.
This commit changes the error message from "Invalid stream id" to "Invalid stream ID" for cases where invalid stream IDs are passed to API endpoints to make it consistent with other similar error messages.
This commit is contained in:
@@ -487,7 +487,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 stream ID")
|
||||
|
||||
stream = self.subscribe(user_profile, "private_stream_1")
|
||||
self.assertFalse(stream.is_in_zephyr_realm)
|
||||
@@ -1326,7 +1326,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 stream ID")
|
||||
|
||||
def test_deactivate_stream_backend_requires_admin(self) -> None:
|
||||
user_profile = self.example_user("hamlet")
|
||||
@@ -1582,7 +1582,7 @@ class StreamAdminTest(ZulipTestCase):
|
||||
"is_private": orjson.dumps(True).decode(),
|
||||
},
|
||||
)
|
||||
self.assert_json_error(result, "Invalid stream id")
|
||||
self.assert_json_error(result, "Invalid stream ID")
|
||||
|
||||
def test_non_admin_cannot_access_unsub_private_stream(self) -> None:
|
||||
iago = self.example_user("iago")
|
||||
@@ -1600,13 +1600,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 stream 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 stream ID")
|
||||
|
||||
result = self.client_patch(
|
||||
f"/json/streams/{stream_id}",
|
||||
@@ -1614,10 +1614,10 @@ class StreamAdminTest(ZulipTestCase):
|
||||
"is_private": orjson.dumps(True).decode(),
|
||||
},
|
||||
)
|
||||
self.assert_json_error(result, "Invalid stream id")
|
||||
self.assert_json_error(result, "Invalid stream ID")
|
||||
|
||||
result = self.client_delete(f"/json/streams/{stream_id}")
|
||||
self.assert_json_error(result, "Invalid stream id")
|
||||
self.assert_json_error(result, "Invalid stream ID")
|
||||
|
||||
def test_change_stream_description(self) -> None:
|
||||
user_profile = self.example_user("iago")
|
||||
@@ -2331,13 +2331,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 stream 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 stream ID")
|
||||
|
||||
def test_delete_public_stream(self) -> None:
|
||||
"""
|
||||
@@ -2734,7 +2734,7 @@ 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 stream ID")
|
||||
|
||||
# Test admin can't add subscribed private stream also.
|
||||
self.subscribe(user_profile, stream_name)
|
||||
@@ -3483,7 +3483,7 @@ class SubscriptionPropertiesTest(ZulipTestCase):
|
||||
).decode()
|
||||
},
|
||||
)
|
||||
self.assert_json_error(result, "Invalid stream id")
|
||||
self.assert_json_error(result, "Invalid stream ID")
|
||||
|
||||
def test_set_invalid_property(self) -> None:
|
||||
"""
|
||||
@@ -3624,7 +3624,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 stream ID")
|
||||
|
||||
def test_bad_add_parameters(self) -> None:
|
||||
user = self.example_user("hamlet")
|
||||
@@ -5499,14 +5499,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 stream 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 stream ID")
|
||||
|
||||
self.login("iago")
|
||||
result = self.client_get(f"/json/streams/{private_stream.id}")
|
||||
@@ -6069,7 +6069,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 stream ID")
|
||||
|
||||
# But an organization administrator can
|
||||
self.login("iago")
|
||||
@@ -6082,7 +6082,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 stream ID")
|
||||
|
||||
def test_json_get_subscribers(self) -> None:
|
||||
"""
|
||||
@@ -6139,7 +6139,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 stream ID")
|
||||
|
||||
# Try to fetch the subscriber list as a non-member & realm-admin-user.
|
||||
self.login("iago")
|
||||
@@ -6162,7 +6162,7 @@ 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 stream ID"):
|
||||
access_stream_by_id(hamlet, 501232)
|
||||
with self.assertRaisesRegex(JsonableError, "Invalid stream name 'invalid stream'"):
|
||||
access_stream_by_name(hamlet, "invalid stream")
|
||||
@@ -6177,7 +6177,7 @@ 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 stream ID"):
|
||||
access_stream_by_id(othello, stream.id)
|
||||
with self.assertRaisesRegex(JsonableError, "Invalid stream name 'new_private_stream'"):
|
||||
access_stream_by_name(othello, stream.name)
|
||||
@@ -6196,17 +6196,17 @@ 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 stream ID"):
|
||||
access_stream_by_id(hamlet, mit_stream.id)
|
||||
with self.assertRaisesRegex(JsonableError, "Invalid stream name 'mit_stream'"):
|
||||
access_stream_by_name(hamlet, mit_stream.name)
|
||||
with self.assertRaisesRegex(JsonableError, "Invalid stream id"):
|
||||
with self.assertRaisesRegex(JsonableError, "Invalid stream ID"):
|
||||
access_stream_by_id(sipbtest, stream.id)
|
||||
with self.assertRaisesRegex(JsonableError, "Invalid stream 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 stream ID"):
|
||||
access_stream_by_id(sipbtest, mit_stream.id)
|
||||
with self.assertRaisesRegex(JsonableError, "Invalid stream name 'mit_stream'"):
|
||||
access_stream_by_name(sipbtest, mit_stream.name)
|
||||
@@ -6223,7 +6223,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 stream ID"):
|
||||
access_stream_by_id(guest_user_profile, stream.id)
|
||||
|
||||
# Guest user have access to subscribed public streams
|
||||
@@ -6236,7 +6236,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 stream ID"):
|
||||
access_stream_by_id(guest_user_profile, stream.id)
|
||||
|
||||
# Guest user have access to subscribed private streams
|
||||
|
||||
Reference in New Issue
Block a user