Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

refactor: Make acting_user a mandatory kwarg for do_change_subscription_property.

shanukun0b3324ba7731
diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py
index ffe597df54a..249158cd1db 100644
--- a/zerver/lib/actions.py
+++ b/zerver/lib/actions.py
@@ -3704,7 +3704,8 @@ def do_change_subscription_property(
stream: Stream,
property_name: str,
value: Any,
- acting_user: Optional[UserProfile] = None,
+ *,
+ acting_user: Optional[UserProfile],
) -> None:
database_property_name = property_name
event_property_name = property_name
diff --git a/zerver/tests/test_event_queue.py b/zerver/tests/test_event_queue.py
index 5b348ea6386..ae72ee648af 100644
--- a/zerver/tests/test_event_queue.py
+++ b/zerver/tests/test_event_queue.py
@@ -355,7 +355,9 @@ class MissedMessageNotificationsTest(ZulipTestCase):
properties: Dict[str, bool],
) -> None:
for property_name, value in properties.items():
- do_change_subscription_property(user_profile, sub, stream, property_name, value)
+ do_change_subscription_property(
+ user_profile, sub, stream, property_name, value, acting_user=None
+ )
def allocate_event_queue() -> ClientDescriptor:
result = self.tornado_call(
diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py
index 4851060c271..c6a93921aab 100644
--- a/zerver/tests/test_events.py
+++ b/zerver/tests/test_events.py
@@ -1093,11 +1093,13 @@ class NormalActionsTest(BaseAction):
def test_change_pin_stream(self) -> None:
stream = get_stream("Denmark", self.user_profile.realm)
sub = get_subscription(stream.name, self.user_profile)
- do_change_subscription_property(self.user_profile, sub, stream, "pin_to_top", False)
+ do_change_subscription_property(
+ self.user_profile, sub, stream, "pin_to_top", False, acting_user=None
+ )
for pinned in (True, False):
events = self.verify_action(
lambda: do_change_subscription_property(
- self.user_profile, sub, stream, "pin_to_top", pinned
+ self.user_profile, sub, stream, "pin_to_top", pinned, acting_user=None
)
)
check_subscription_update(
@@ -1116,7 +1118,7 @@ class NormalActionsTest(BaseAction):
for value in (True, False):
events = self.verify_action(
lambda: do_change_subscription_property(
- self.user_profile, sub, stream, setting_name, value
+ self.user_profile, sub, stream, setting_name, value, acting_user=None
),
notification_settings_null=True,
)
@@ -1130,7 +1132,7 @@ class NormalActionsTest(BaseAction):
for value in (True, False):
events = self.verify_action(
lambda: do_change_subscription_property(
- self.user_profile, sub, stream, setting_name, value
+ self.user_profile, sub, stream, setting_name, value, acting_user=None
)
)
check_subscription_update(
diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py
index a018bc4ec88..4a2ff183853 100644
--- a/zerver/tests/test_subs.py
+++ b/zerver/tests/test_subs.py
@@ -401,7 +401,12 @@ class StreamAdminTest(ZulipTestCase):
sub = get_subscription("private_stream_2", user_profile)
do_change_subscription_property(
- user_profile, sub, stream, "role", Subscription.ROLE_STREAM_ADMINISTRATOR
+ user_profile,
+ sub,
+ stream,
+ "role",
+ Subscription.ROLE_STREAM_ADMINISTRATOR,
+ acting_user=None,
)
result = self.client_patch(f"/json/streams/{stream.id}", params)
self.assert_json_success(result)
@@ -451,7 +456,12 @@ class StreamAdminTest(ZulipTestCase):
sub = get_subscription("public_stream_2", user_profile)
do_change_subscription_property(
- user_profile, sub, stream, "role", Subscription.ROLE_STREAM_ADMINISTRATOR
+ user_profile,
+ sub,
+ stream,
+ "role",
+ Subscription.ROLE_STREAM_ADMINISTRATOR,
+ acting_user=None,
)
result = self.client_patch(f"/json/streams/{stream.id}", params)
self.assert_json_success(result)
@@ -572,7 +582,12 @@ class StreamAdminTest(ZulipTestCase):
self.subscribe(user_profile, stream.name)
sub = get_subscription(stream.name, user_profile)
do_change_subscription_property(
- user_profile, sub, stream, "role", Subscription.ROLE_STREAM_ADMINISTRATOR
+ user_profile,
+ sub,
+ stream,
+ "role",
+ Subscription.ROLE_STREAM_ADMINISTRATOR,
+ acting_user=None,
)
result = self.client_delete(f"/json/streams/{stream.id}")
@@ -859,7 +874,12 @@ class StreamAdminTest(ZulipTestCase):
self.subscribe(user_profile, "new_stream")
sub = get_subscription("new_stream", user_profile)
do_change_subscription_property(
- user_profile, sub, new_stream, "role", Subscription.ROLE_STREAM_ADMINISTRATOR
+ user_profile,
+ sub,
+ new_stream,
+ "role",
+ Subscription.ROLE_STREAM_ADMINISTRATOR,
+ acting_user=None,
)
del events[:]
with tornado_redirected_to_list(events):
@@ -1055,7 +1075,12 @@ class StreamAdminTest(ZulipTestCase):
do_change_user_role(user_profile, UserProfile.ROLE_MEMBER, acting_user=None)
sub = get_subscription("stream_name1", user_profile)
do_change_subscription_property(
- user_profile, sub, stream, "role", Subscription.ROLE_STREAM_ADMINISTRATOR
+ user_profile,
+ sub,
+ stream,
+ "role",
+ Subscription.ROLE_STREAM_ADMINISTRATOR,
+ acting_user=None,
)
with tornado_redirected_to_list(events):
@@ -1076,7 +1101,9 @@ class StreamAdminTest(ZulipTestCase):
sub = get_subscription("stream_name1", user_profile)
do_change_user_role(user_profile, UserProfile.ROLE_MEMBER, acting_user=None)
- do_change_subscription_property(user_profile, sub, stream, "role", Subscription.ROLE_MEMBER)
+ do_change_subscription_property(
+ user_profile, sub, stream, "role", Subscription.ROLE_MEMBER, acting_user=None
+ )
stream_id = get_stream("stream_name1", user_profile.realm).id
result = self.client_patch(
@@ -1107,7 +1134,9 @@ class StreamAdminTest(ZulipTestCase):
sub = get_subscription("stream_name1", user_profile)
do_change_user_role(user_profile, UserProfile.ROLE_MEMBER, acting_user=None)
- do_change_subscription_property(user_profile, sub, stream, "role", Subscription.ROLE_MEMBER)
+ do_change_subscription_property(
+ user_profile, sub, stream, "role", Subscription.ROLE_MEMBER, acting_user=None
+ )
do_set_realm_property(user_profile.realm, "waiting_period_threshold", 10, acting_user=None)
@@ -1132,7 +1161,12 @@ class StreamAdminTest(ZulipTestCase):
test_non_admin(how_old=5, is_new=True, policy=policy)
do_change_subscription_property(
- user_profile, sub, stream, "role", Subscription.ROLE_STREAM_ADMINISTRATOR
+ user_profile,
+ sub,
+ stream,
+ "role",
+ Subscription.ROLE_STREAM_ADMINISTRATOR,
+ acting_user=None,
)
for policy in policies:
@@ -1498,7 +1532,12 @@ class StreamAdminTest(ZulipTestCase):
if is_stream_admin:
sub = get_subscription(stream_name, user_profile)
do_change_subscription_property(
- user_profile, sub, stream, "role", Subscription.ROLE_STREAM_ADMINISTRATOR
+ user_profile,
+ sub,
+ stream,
+ "role",
+ Subscription.ROLE_STREAM_ADMINISTRATOR,
+ acting_user=None,
)
if target_users_subbed:
for user in target_users: