mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 00:18:12 +00:00
user_groups: Use UserGroupMembersDict in initial state data.
On the event side, orjson does the work of converting UserGroupMembersData to json. But when fetching intial state data, UserGroupMembersData was being returned which is not json-serializable. This was causing a mismatch in the `verify_action` workflow of test_events related to stream group settings where apply_events resulted in a state with `direct_members` and `direct_subgroups` as part of an ordinary dict, while fetching initial state data was giving us a UserGroupMembersData class. This commit uses UserGroupMembersDict where appropriate. It will still be good to keep around the dataclass class since it has the added benefit of storing the relevant value when needed.
This commit is contained in:
committed by
Tim Abbott
parent
37d91d9759
commit
b3862c5008
@@ -115,7 +115,7 @@ from zerver.lib.event_types import (
|
||||
PlanTypeData,
|
||||
)
|
||||
from zerver.lib.topic import ORIG_TOPIC, TOPIC_NAME
|
||||
from zerver.lib.types import UserGroupMembersData
|
||||
from zerver.lib.types import UserGroupMembersDict
|
||||
from zerver.models import Realm, RealmUserDefault, Stream, UserProfile
|
||||
|
||||
|
||||
@@ -549,7 +549,13 @@ def check_stream_update(
|
||||
assert value in Stream.STREAM_POST_POLICY_TYPES
|
||||
elif prop in Stream.stream_permission_group_settings:
|
||||
assert extra_keys == set()
|
||||
assert isinstance(value, int | UserGroupMembersData)
|
||||
assert isinstance(value, int | dict)
|
||||
# We cannot validate a TypedDict using isinstance, thus
|
||||
# requiring this check.
|
||||
if isinstance(value, dict):
|
||||
expected_keys = set(inspect.get_annotations(UserGroupMembersDict).keys())
|
||||
keys = set(value.keys())
|
||||
assert expected_keys == keys
|
||||
elif prop == "first_message_id":
|
||||
assert extra_keys == set()
|
||||
assert isinstance(value, int)
|
||||
|
||||
Reference in New Issue
Block a user