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.