tests: Move test to check permission to update message retention setting.

This commit moves test to check permission to update message retention
setting of a stream to test_channel_permissions.py.
This commit is contained in:
Sahil Batra
2025-06-09 17:29:55 +05:30
committed by Tim Abbott
parent 0dee5f4c0d
commit 79c2972232
2 changed files with 19 additions and 19 deletions

View File

@@ -727,3 +727,22 @@ class ChannelSubscriptionPermissionTest(ZulipTestCase):
stream_list=[private_stream, private_stream_2],
skip_changing_group_setting=True,
)
def test_change_stream_message_retention_days_requires_realm_owner(self) -> None:
user_profile = self.example_user("iago")
self.login_user(user_profile)
realm = user_profile.realm
stream = self.subscribe(user_profile, "stream_name1")
result = self.client_patch(
f"/json/streams/{stream.id}", {"message_retention_days": orjson.dumps(2).decode()}
)
self.assert_json_error(result, "Must be an organization owner")
do_change_user_role(user_profile, UserProfile.ROLE_REALM_OWNER, acting_user=None)
result = self.client_patch(
f"/json/streams/{stream.id}", {"message_retention_days": orjson.dumps(2).decode()}
)
self.assert_json_success(result)
stream = get_stream("stream_name1", realm)
self.assertEqual(stream.message_retention_days, 2)

View File

@@ -2207,25 +2207,6 @@ class StreamAdminTest(ZulipTestCase):
)
self.assert_json_error(result, "Bad value for 'message_retention_days': 0")
def test_change_stream_message_retention_days_requires_realm_owner(self) -> None:
user_profile = self.example_user("iago")
self.login_user(user_profile)
realm = user_profile.realm
stream = self.subscribe(user_profile, "stream_name1")
result = self.client_patch(
f"/json/streams/{stream.id}", {"message_retention_days": orjson.dumps(2).decode()}
)
self.assert_json_error(result, "Must be an organization owner")
do_change_user_role(user_profile, UserProfile.ROLE_REALM_OWNER, acting_user=None)
result = self.client_patch(
f"/json/streams/{stream.id}", {"message_retention_days": orjson.dumps(2).decode()}
)
self.assert_json_success(result)
stream = get_stream("stream_name1", realm)
self.assertEqual(stream.message_retention_days, 2)
def do_test_change_stream_permission_setting(self, setting_name: str) -> None:
user_profile = self.example_user("iago")
realm = user_profile.realm