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.
This commit is contained in:
Ganesh Pawar 2021-03-26 13:05:22 +05:30 committed by Tim Abbott
parent 113e27615d
commit eca2e10c4a
1 changed files with 7 additions and 4 deletions

View File

@ -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.