mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
refactor: Make acting_user a mandatory kwarg for bulk_remove_subscriptions.
This commit is contained in:
@@ -3557,7 +3557,8 @@ def bulk_remove_subscriptions(
|
|||||||
users: Iterable[UserProfile],
|
users: Iterable[UserProfile],
|
||||||
streams: Iterable[Stream],
|
streams: Iterable[Stream],
|
||||||
acting_client: Client,
|
acting_client: Client,
|
||||||
acting_user: Optional[UserProfile] = None,
|
*,
|
||||||
|
acting_user: Optional[UserProfile],
|
||||||
) -> SubAndRemovedT:
|
) -> SubAndRemovedT:
|
||||||
|
|
||||||
users = list(users)
|
users = list(users)
|
||||||
|
|||||||
@@ -965,7 +965,7 @@ Output:
|
|||||||
def unsubscribe(self, user_profile: UserProfile, stream_name: str) -> None:
|
def unsubscribe(self, user_profile: UserProfile, stream_name: str) -> None:
|
||||||
client = get_client("website")
|
client = get_client("website")
|
||||||
stream = get_stream(stream_name, user_profile.realm)
|
stream = get_stream(stream_name, user_profile.realm)
|
||||||
bulk_remove_subscriptions([user_profile], [stream], client)
|
bulk_remove_subscriptions([user_profile], [stream], client, acting_user=None)
|
||||||
|
|
||||||
# Subscribe to a stream by making an API request
|
# Subscribe to a stream by making an API request
|
||||||
def common_subscribe_to_streams(
|
def common_subscribe_to_streams(
|
||||||
|
|||||||
@@ -1570,7 +1570,7 @@ class NormalActionsTest(BaseAction):
|
|||||||
stream = get_stream("test_stream", self.user_profile.realm)
|
stream = get_stream("test_stream", self.user_profile.realm)
|
||||||
|
|
||||||
action = lambda: bulk_remove_subscriptions(
|
action = lambda: bulk_remove_subscriptions(
|
||||||
[self.example_user("othello")], [stream], get_client("website")
|
[self.example_user("othello")], [stream], get_client("website"), acting_user=None
|
||||||
)
|
)
|
||||||
events = self.verify_action(action)
|
events = self.verify_action(action)
|
||||||
check_subscription_peer_remove("events[0]", events[0])
|
check_subscription_peer_remove("events[0]", events[0])
|
||||||
@@ -1968,7 +1968,7 @@ class SubscribeActionTest(BaseAction):
|
|||||||
# Now remove the first user, to test the normal unsubscribe flow and
|
# Now remove the first user, to test the normal unsubscribe flow and
|
||||||
# 'peer_remove' event for subscribed streams.
|
# 'peer_remove' event for subscribed streams.
|
||||||
action = lambda: bulk_remove_subscriptions(
|
action = lambda: bulk_remove_subscriptions(
|
||||||
[self.example_user("othello")], [stream], get_client("website")
|
[self.example_user("othello")], [stream], get_client("website"), acting_user=None
|
||||||
)
|
)
|
||||||
events = self.verify_action(
|
events = self.verify_action(
|
||||||
action,
|
action,
|
||||||
@@ -1979,7 +1979,7 @@ class SubscribeActionTest(BaseAction):
|
|||||||
|
|
||||||
# Now remove the user himself, to test the 'remove' event flow
|
# Now remove the user himself, to test the 'remove' event flow
|
||||||
action = lambda: bulk_remove_subscriptions(
|
action = lambda: bulk_remove_subscriptions(
|
||||||
[self.example_user("hamlet")], [stream], get_client("website")
|
[self.example_user("hamlet")], [stream], get_client("website"), acting_user=None
|
||||||
)
|
)
|
||||||
events = self.verify_action(
|
events = self.verify_action(
|
||||||
action, include_subscribers=include_subscribers, include_streams=False, num_events=2
|
action, include_subscribers=include_subscribers, include_streams=False, num_events=2
|
||||||
@@ -2003,7 +2003,7 @@ class SubscribeActionTest(BaseAction):
|
|||||||
|
|
||||||
# Remove the user to test 'peer_remove' event flow for unsubscribed stream.
|
# Remove the user to test 'peer_remove' event flow for unsubscribed stream.
|
||||||
action = lambda: bulk_remove_subscriptions(
|
action = lambda: bulk_remove_subscriptions(
|
||||||
[self.example_user("iago")], [stream], get_client("website")
|
[self.example_user("iago")], [stream], get_client("website"), acting_user=None
|
||||||
)
|
)
|
||||||
events = self.verify_action(
|
events = self.verify_action(
|
||||||
action,
|
action,
|
||||||
|
|||||||
@@ -3865,6 +3865,7 @@ class SubscriptionAPITest(ZulipTestCase):
|
|||||||
[user1, user2],
|
[user1, user2],
|
||||||
[stream1, stream2, stream3, private],
|
[stream1, stream2, stream3, private],
|
||||||
get_client("website"),
|
get_client("website"),
|
||||||
|
acting_user=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assert_length(query_count, 28)
|
self.assert_length(query_count, 28)
|
||||||
@@ -3934,6 +3935,7 @@ class SubscriptionAPITest(ZulipTestCase):
|
|||||||
users=[mit_user],
|
users=[mit_user],
|
||||||
streams=streams,
|
streams=streams,
|
||||||
acting_client=get_client("website"),
|
acting_client=get_client("website"),
|
||||||
|
acting_user=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assert_length(events, 0)
|
self.assert_length(events, 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user