Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

test_channel_folders: Add test for long name and description.

Sahil Batra945e5553e430
diff --git a/zerver/tests/test_channel_folders.py b/zerver/tests/test_channel_folders.py
index c1a8cb7dd29..335f8418bc0 100644
--- a/zerver/tests/test_channel_folders.py
+++ b/zerver/tests/test_channel_folders.py
@@ -69,7 +69,7 @@ class ChannelFolderCreationTest(ZulipTestCase):
"<p>Channels for <strong>backend</strong> discussions</p>",
)
- def test_invalid_names_for_channel_folder(self) -> None:
+ def test_invalid_params_for_channel_folder(self) -> None:
self.login("iago")
params = {"name": "", "description": "Channels for frontend discussions"}
@@ -81,6 +81,21 @@ class ChannelFolderCreationTest(ZulipTestCase):
result = self.client_post("/json/channel_folders/create", params)
self.assert_json_error(result, "Invalid character in channel folder name, at position 4.")
+ long_name = "a" * (ChannelFolder.MAX_NAME_LENGTH + 1)
+ params = {"name": long_name, "description": "Channels for frontend discussions"}
+ result = self.client_post("/json/channel_folders/create", params)
+ self.assert_json_error(
+ result, f"name is too long (limit: {ChannelFolder.MAX_NAME_LENGTH} characters)"
+ )
+
+ long_description = "a" * (ChannelFolder.MAX_DESCRIPTION_LENGTH + 1)
+ params = {"name": "Frontend", "description": long_description}
+ result = self.client_post("/json/channel_folders/create", params)
+ self.assert_json_error(
+ result,
+ f"description is too long (limit: {ChannelFolder.MAX_DESCRIPTION_LENGTH} characters)",
+ )
+
class GetChannelFoldersTest(ZulipTestCase):
def test_get_channel_folders(self) -> None: