From eca2e10c4a43b32a0115eda0c7f803e9f03ce967 Mon Sep 17 00:00:00 2001 From: Ganesh Pawar Date: Fri, 26 Mar 2021 13:05:22 +0530 Subject: [PATCH] test_realm: Extract out test_change_stream_creation_policy. This is a prep commit in preparation of splitting create_stream_policy into create_private_stream_policy and create_public_stream_policy. This extracts it in a way to make it possible to easily test different stream policies in the upcoming stream policy split. --- zerver/tests/test_realm.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py index 1dbf68769e..5a25351cab 100644 --- a/zerver/tests/test_realm.py +++ b/zerver/tests/test_realm.py @@ -484,17 +484,20 @@ class RealmTest(ZulipTestCase): realm = get_realm("zulip") self.assertEqual(realm.email_address_visibility, Realm.EMAIL_ADDRESS_VISIBILITY_ADMINS) - def test_change_stream_creation_policy(self) -> None: + def _test_change_stream_creation_policy(self, stream_policy: str) -> None: # We need an admin user. self.login("iago") - req = dict(create_stream_policy=orjson.dumps(Realm.POLICY_ADMINS_ONLY).decode()) + req = {stream_policy: orjson.dumps(Realm.POLICY_ADMINS_ONLY).decode()} result = self.client_patch("/json/realm", req) self.assert_json_success(result) invalid_value = 10 - req = dict(create_stream_policy=orjson.dumps(invalid_value).decode()) + req = {stream_policy: orjson.dumps(invalid_value).decode()} result = self.client_patch("/json/realm", req) - self.assert_json_error(result, "Invalid create_stream_policy") + self.assert_json_error(result, f"Invalid {stream_policy}") + + def test_change_stream_creation_policy(self) -> None: + self._test_change_stream_creation_policy("create_stream_policy") def test_change_invite_to_stream_policy(self) -> None: # We need an admin user.