mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
test_realm: Improve do_test_realm_update_api.
This commit improves how we handle video_chat_provider
and jitsi_server_url settings in do_test_realm_update_api.
For video_chat_provider, there is no use for calling
update_with_api_multiple_value and it can be handled
similar to other tests, so did that change and also
added one more value to test, so that it actually
tests changing the setting.
We need to handle jitsi_server_url separately as even
though value is a string, we need to serialize to
JSON. We do not use a separate function for it as
this is the only setting to handle differently and
update_with_api_multiple_value anyways was added in
bbff797a93 to update multiple settings in a request
which we are not doing here.
As a result of above changes, update_with_api_multiple_value
function is also removed.
This commit is contained in:
@@ -1447,11 +1447,6 @@ class RealmAPITest(ZulipTestCase):
|
||||
self.assert_json_success(result)
|
||||
return get_realm("zulip") # refresh data
|
||||
|
||||
def update_with_api_multiple_value(self, data_dict: Dict[str, Any]) -> Realm:
|
||||
result = self.client_patch("/json/realm", data_dict)
|
||||
self.assert_json_success(result)
|
||||
return get_realm("zulip")
|
||||
|
||||
def do_test_realm_update_api(self, name: str) -> None:
|
||||
"""Test updating realm properties.
|
||||
|
||||
@@ -1478,17 +1473,10 @@ class RealmAPITest(ZulipTestCase):
|
||||
wildcard_mention_policy=Realm.WILDCARD_MENTION_POLICY_TYPES,
|
||||
bot_creation_policy=Realm.BOT_CREATION_POLICY_TYPES,
|
||||
video_chat_provider=[
|
||||
dict(
|
||||
video_chat_provider=orjson.dumps(
|
||||
Realm.VIDEO_CHAT_PROVIDERS["jitsi_meet"]["id"]
|
||||
).decode(),
|
||||
),
|
||||
],
|
||||
jitsi_server_url=[
|
||||
dict(
|
||||
jitsi_server_url=orjson.dumps("https://example.jit.si").decode(),
|
||||
),
|
||||
Realm.VIDEO_CHAT_PROVIDERS["jitsi_meet"]["id"],
|
||||
Realm.VIDEO_CHAT_PROVIDERS["disabled"]["id"],
|
||||
],
|
||||
jitsi_server_url=["https://example.jit.si"],
|
||||
giphy_rating=[
|
||||
Realm.GIPHY_RATING_OPTIONS["y"]["id"],
|
||||
Realm.GIPHY_RATING_OPTIONS["r"]["id"],
|
||||
@@ -1510,10 +1498,14 @@ class RealmAPITest(ZulipTestCase):
|
||||
if vals is None:
|
||||
raise AssertionError(f"No test created for {name}")
|
||||
|
||||
if name in ("video_chat_provider", "jitsi_server_url"):
|
||||
self.set_up_db(name, vals[0][name])
|
||||
realm = self.update_with_api_multiple_value(vals[0])
|
||||
self.assertEqual(getattr(realm, name), orjson.loads(vals[0][name]))
|
||||
if name == "jitsi_server_url":
|
||||
realm = get_realm("zulip")
|
||||
self.assertIsNone(realm.jitsi_server_url, None)
|
||||
realm = self.update_with_api(name, orjson.dumps(vals[0]).decode())
|
||||
self.assertEqual(realm.jitsi_server_url, vals[0])
|
||||
|
||||
realm = self.update_with_api(name, orjson.dumps("default").decode())
|
||||
self.assertIsNone(realm.jitsi_server_url, None)
|
||||
return
|
||||
|
||||
self.set_up_db(name, vals[0])
|
||||
|
||||
Reference in New Issue
Block a user