refactor: Make acting_user a mandatory kwarg for do_deactivate_stream.

This commit is contained in:
shanukun
2021-04-02 21:19:36 +05:30
committed by Tim Abbott
parent f442e9fb03
commit c39ffe8811
5 changed files with 8 additions and 8 deletions

View File

@@ -1206,7 +1206,7 @@ def do_deactivate_user(
def do_deactivate_stream(
stream: Stream, log: bool = True, acting_user: Optional[UserProfile] = None
stream: Stream, log: bool = True, *, acting_user: Optional[UserProfile]
) -> None:
# We want to mark all messages in the to-be-deactivated stream as
# read for all users; otherwise they will pollute queries like

View File

@@ -76,7 +76,7 @@ class GlobalPublicStreamTest(ZulipTestCase):
self.assert_length(info.never_subscribed, 0)
self.assertNotEqual(info.subscriptions[0]["color"], info.subscriptions[1]["color"])
do_deactivate_stream(test_stream)
do_deactivate_stream(test_stream, acting_user=None)
public_streams = get_web_public_streams(realm)
self.assert_length(public_streams, 1)
info = get_web_public_subs(realm)

View File

@@ -1555,7 +1555,7 @@ class NormalActionsTest(BaseAction):
def test_deactivate_stream_neversubscribed(self) -> None:
for i, include_streams in enumerate([True, False]):
stream = self.make_stream(f"stream{i}")
action = lambda: do_deactivate_stream(stream)
action = lambda: do_deactivate_stream(stream, acting_user=None)
events = self.verify_action(action, include_streams=include_streams)
check_stream_delete("events[0]", events[0])

View File

@@ -341,7 +341,7 @@ class RealmTest(ZulipTestCase):
notifications_stream = realm.get_notifications_stream()
assert notifications_stream is not None
self.assertEqual(notifications_stream.id, verona.id)
do_deactivate_stream(notifications_stream)
do_deactivate_stream(notifications_stream, acting_user=None)
self.assertIsNone(realm.get_notifications_stream())
def test_change_signup_notifications_stream(self) -> None:
@@ -393,7 +393,7 @@ class RealmTest(ZulipTestCase):
signup_notifications_stream = realm.get_signup_notifications_stream()
assert signup_notifications_stream is not None
self.assertEqual(signup_notifications_stream, verona)
do_deactivate_stream(signup_notifications_stream)
do_deactivate_stream(signup_notifications_stream, acting_user=None)
self.assertIsNone(realm.get_signup_notifications_stream())
def test_change_realm_default_language(self) -> None:

View File

@@ -555,7 +555,7 @@ class StreamAdminTest(ZulipTestCase):
stream = self.make_stream("new_stream")
do_add_default_stream(stream)
self.assertEqual(1, DefaultStream.objects.filter(stream_id=stream.id).count())
do_deactivate_stream(stream)
do_deactivate_stream(stream, acting_user=None)
self.assertEqual(0, DefaultStream.objects.filter(stream_id=stream.id).count())
def test_deactivate_stream_removes_stream_from_default_stream_groups(self) -> None:
@@ -580,7 +580,7 @@ class StreamAdminTest(ZulipTestCase):
default_stream_groups = get_default_stream_groups(realm)
self.assertEqual(get_streams(default_stream_groups[0]), all_streams)
do_deactivate_stream(streams_to_remove[0])
do_deactivate_stream(streams_to_remove[0], acting_user=None)
self.assertEqual(get_streams(default_stream_groups[0]), streams_to_keep)
def test_deactivate_stream_marks_messages_as_read(self) -> None:
@@ -603,7 +603,7 @@ class StreamAdminTest(ZulipTestCase):
self.assertFalse(new_stream_usermessage.flags.read)
self.assertFalse(denmark_usermessage.flags.read)
do_deactivate_stream(stream)
do_deactivate_stream(stream, acting_user=None)
new_stream_usermessage.refresh_from_db()
denmark_usermessage.refresh_from_db()
self.assertTrue(new_stream_usermessage.flags.read)