mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	tornado_redirected_to_list: Make expected_num_events required argument.
Follow up to 481a890ec5.
This will make this more explicit and readable.
			
			
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							07f972f45a
						
					
				
				
					commit
					3039a01b31
				
			@@ -1259,7 +1259,7 @@ Output:
 | 
			
		||||
 | 
			
		||||
    @contextmanager
 | 
			
		||||
    def tornado_redirected_to_list(
 | 
			
		||||
        self, lst: List[Mapping[str, Any]], expected_num_events: int = 1
 | 
			
		||||
        self, lst: List[Mapping[str, Any]], expected_num_events: int
 | 
			
		||||
    ) -> Iterator[None]:
 | 
			
		||||
        real_event_queue_process_notification = django_tornado_api.process_notification
 | 
			
		||||
        django_tornado_api.process_notification = lambda notice: lst.append(notice)
 | 
			
		||||
 
 | 
			
		||||
@@ -225,7 +225,7 @@ class UnreadCountTests(ZulipTestCase):
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.client_post(
 | 
			
		||||
                "/json/mark_stream_as_read",
 | 
			
		||||
                {
 | 
			
		||||
@@ -295,7 +295,7 @@ class UnreadCountTests(ZulipTestCase):
 | 
			
		||||
            self.example_user("hamlet"), "Denmark", "hello", "Denmark2"
 | 
			
		||||
        )
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.client_post(
 | 
			
		||||
                "/json/mark_topic_as_read",
 | 
			
		||||
                {
 | 
			
		||||
 
 | 
			
		||||
@@ -1661,7 +1661,7 @@ class StreamMessagesTest(ZulipTestCase):
 | 
			
		||||
 | 
			
		||||
    def _send_stream_message(self, user: UserProfile, stream_name: str, content: str) -> Set[int]:
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            self.send_stream_message(
 | 
			
		||||
                user,
 | 
			
		||||
                stream_name,
 | 
			
		||||
 
 | 
			
		||||
@@ -418,7 +418,7 @@ class ReactionEventTest(ZulipTestCase):
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.api_post(
 | 
			
		||||
                reaction_sender, f"/api/v1/messages/{pm_id}/reactions", reaction_info
 | 
			
		||||
            )
 | 
			
		||||
@@ -462,7 +462,7 @@ class ReactionEventTest(ZulipTestCase):
 | 
			
		||||
        self.assert_json_success(add)
 | 
			
		||||
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.api_delete(
 | 
			
		||||
                reaction_sender, f"/api/v1/messages/{pm_id}/reactions", reaction_info
 | 
			
		||||
            )
 | 
			
		||||
@@ -500,7 +500,7 @@ class ReactionEventTest(ZulipTestCase):
 | 
			
		||||
        # Hamlet and Polonius joined after the message was sent, and
 | 
			
		||||
        # so only Iago should receive the event.
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.api_post(
 | 
			
		||||
                iago, f"/api/v1/messages/{message_before_id}/reactions", reaction_info
 | 
			
		||||
            )
 | 
			
		||||
@@ -520,7 +520,7 @@ class ReactionEventTest(ZulipTestCase):
 | 
			
		||||
            iago, "test_reactions_stream", "after subscription history private"
 | 
			
		||||
        )
 | 
			
		||||
        events = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.api_post(
 | 
			
		||||
                iago, f"/api/v1/messages/{message_after_id}/reactions", reaction_info
 | 
			
		||||
            )
 | 
			
		||||
@@ -540,7 +540,7 @@ class ReactionEventTest(ZulipTestCase):
 | 
			
		||||
        # message_before_id should notify all subscribers:
 | 
			
		||||
        # Iago and Hamlet.
 | 
			
		||||
        events = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.api_post(
 | 
			
		||||
                iago, f"/api/v1/messages/{message_before_id}/reactions", reaction_info
 | 
			
		||||
            )
 | 
			
		||||
@@ -559,7 +559,7 @@ class ReactionEventTest(ZulipTestCase):
 | 
			
		||||
        # For is_web_public streams, events even on old messages
 | 
			
		||||
        # should go to all subscribers, including guests like polonius.
 | 
			
		||||
        events = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.api_post(
 | 
			
		||||
                iago, f"/api/v1/messages/{message_before_id}/reactions", reaction_info
 | 
			
		||||
            )
 | 
			
		||||
@@ -580,7 +580,7 @@ class ReactionEventTest(ZulipTestCase):
 | 
			
		||||
            "hello to single receiver",
 | 
			
		||||
        )
 | 
			
		||||
        events = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.api_post(
 | 
			
		||||
                hamlet, f"/api/v1/messages/{private_message_id}/reactions", reaction_info
 | 
			
		||||
            )
 | 
			
		||||
@@ -597,7 +597,7 @@ class ReactionEventTest(ZulipTestCase):
 | 
			
		||||
            "hello message to muliple receiver",
 | 
			
		||||
        )
 | 
			
		||||
        events = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.api_post(
 | 
			
		||||
                polonius, f"/api/v1/messages/{huddle_message_id}/reactions", reaction_info
 | 
			
		||||
            )
 | 
			
		||||
@@ -1027,7 +1027,7 @@ class ReactionAPIEventTest(EmojiReactionBase):
 | 
			
		||||
            "reaction_type": "unicode_emoji",
 | 
			
		||||
        }
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            self.api_post(reaction_sender, f"/api/v1/messages/{pm_id}/reactions", reaction_info)
 | 
			
		||||
 | 
			
		||||
        event = events[0]["event"]
 | 
			
		||||
@@ -1067,7 +1067,7 @@ class ReactionAPIEventTest(EmojiReactionBase):
 | 
			
		||||
        self.assert_json_success(add)
 | 
			
		||||
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.api_delete(
 | 
			
		||||
                reaction_sender,
 | 
			
		||||
                f"/api/v1/messages/{pm_id}/reactions",
 | 
			
		||||
 
 | 
			
		||||
@@ -69,7 +69,7 @@ class RealmTest(ZulipTestCase):
 | 
			
		||||
        realm = get_realm("zulip")
 | 
			
		||||
        new_name = "Puliz"
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            do_set_realm_property(realm, "name", new_name, acting_user=None)
 | 
			
		||||
        event = events[0]["event"]
 | 
			
		||||
        self.assertEqual(
 | 
			
		||||
@@ -86,7 +86,7 @@ class RealmTest(ZulipTestCase):
 | 
			
		||||
        realm = get_realm("zulip")
 | 
			
		||||
        new_description = "zulip dev group"
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            do_set_realm_property(realm, "description", new_description, acting_user=None)
 | 
			
		||||
        event = events[0]["event"]
 | 
			
		||||
        self.assertEqual(
 | 
			
		||||
@@ -104,7 +104,7 @@ class RealmTest(ZulipTestCase):
 | 
			
		||||
        new_description = "zulip dev group"
 | 
			
		||||
        data = dict(description=new_description)
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.client_patch("/json/realm", data)
 | 
			
		||||
            self.assert_json_success(result)
 | 
			
		||||
            realm = get_realm("zulip")
 | 
			
		||||
 
 | 
			
		||||
@@ -114,7 +114,7 @@ class TestBasics(ZulipTestCase):
 | 
			
		||||
            content='{"name": "alice", "salary": 20}',
 | 
			
		||||
        )
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.client_post("/json/submessage", payload)
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -122,7 +122,7 @@ class TestCreateStreams(ZulipTestCase):
 | 
			
		||||
 | 
			
		||||
        # Test stream creation events.
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            ensure_stream(realm, "Public stream", invite_only=False, acting_user=None)
 | 
			
		||||
 | 
			
		||||
        self.assertEqual(events[0]["event"]["type"], "stream")
 | 
			
		||||
@@ -132,7 +132,7 @@ class TestCreateStreams(ZulipTestCase):
 | 
			
		||||
        self.assertEqual(events[0]["event"]["streams"][0]["name"], "Public stream")
 | 
			
		||||
 | 
			
		||||
        events = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            ensure_stream(realm, "Private stream", invite_only=True, acting_user=None)
 | 
			
		||||
 | 
			
		||||
        self.assertEqual(events[0]["event"]["type"], "stream")
 | 
			
		||||
@@ -708,7 +708,7 @@ class StreamAdminTest(ZulipTestCase):
 | 
			
		||||
        self.subscribe(self.example_user("cordelia"), "private_stream")
 | 
			
		||||
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            stream_id = get_stream("private_stream", user_profile.realm).id
 | 
			
		||||
            result = self.client_patch(
 | 
			
		||||
                f"/json/streams/{stream_id}",
 | 
			
		||||
@@ -989,7 +989,7 @@ class StreamAdminTest(ZulipTestCase):
 | 
			
		||||
        self.subscribe(user_profile, "stream_name1")
 | 
			
		||||
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            stream_id = get_stream("stream_name1", realm).id
 | 
			
		||||
            result = self.client_patch(
 | 
			
		||||
                f"/json/streams/{stream_id}",
 | 
			
		||||
@@ -1179,7 +1179,7 @@ class StreamAdminTest(ZulipTestCase):
 | 
			
		||||
 | 
			
		||||
        do_change_plan_type(realm, Realm.SELF_HOSTED, acting_user=None)
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.client_patch(
 | 
			
		||||
                f"/json/streams/{stream.id}", {"message_retention_days": orjson.dumps(2).decode()}
 | 
			
		||||
            )
 | 
			
		||||
@@ -1207,7 +1207,7 @@ class StreamAdminTest(ZulipTestCase):
 | 
			
		||||
        self.assertEqual(stream.message_retention_days, 2)
 | 
			
		||||
 | 
			
		||||
        events = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.client_patch(
 | 
			
		||||
                f"/json/streams/{stream.id}",
 | 
			
		||||
                {"message_retention_days": orjson.dumps("forever").decode()},
 | 
			
		||||
@@ -1230,7 +1230,7 @@ class StreamAdminTest(ZulipTestCase):
 | 
			
		||||
        self.assertEqual(stream.message_retention_days, -1)
 | 
			
		||||
 | 
			
		||||
        events = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.client_patch(
 | 
			
		||||
                f"/json/streams/{stream.id}",
 | 
			
		||||
                {"message_retention_days": orjson.dumps("realm_default").decode()},
 | 
			
		||||
@@ -1380,7 +1380,7 @@ class StreamAdminTest(ZulipTestCase):
 | 
			
		||||
        ensure_stream(realm, "DB32B77" + "!DEACTIVATED:" + active_name, acting_user=None)
 | 
			
		||||
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.client_delete("/json/streams/" + str(stream_id))
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
 | 
			
		||||
@@ -2532,7 +2532,7 @@ class SubscriptionPropertiesTest(ZulipTestCase):
 | 
			
		||||
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        property_name = "is_muted"
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.api_post(
 | 
			
		||||
                test_user,
 | 
			
		||||
                "/api/v1/users/me/subscriptions/properties",
 | 
			
		||||
@@ -2560,7 +2560,7 @@ class SubscriptionPropertiesTest(ZulipTestCase):
 | 
			
		||||
 | 
			
		||||
        events = []
 | 
			
		||||
        legacy_property_name = "in_home_view"
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.api_post(
 | 
			
		||||
                test_user,
 | 
			
		||||
                "/api/v1/users/me/subscriptions/properties",
 | 
			
		||||
@@ -2588,7 +2588,7 @@ class SubscriptionPropertiesTest(ZulipTestCase):
 | 
			
		||||
        self.assertEqual(sub.is_muted, False)
 | 
			
		||||
 | 
			
		||||
        events = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.api_post(
 | 
			
		||||
                test_user,
 | 
			
		||||
                "/api/v1/users/me/subscriptions/properties",
 | 
			
		||||
 
 | 
			
		||||
@@ -149,7 +149,7 @@ class TypingHappyPathTestPMs(ZulipTestCase):
 | 
			
		||||
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with queries_captured() as queries:
 | 
			
		||||
            with self.tornado_redirected_to_list(events):
 | 
			
		||||
            with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
                result = self.api_post(sender, "/api/v1/typing", params)
 | 
			
		||||
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
@@ -186,7 +186,7 @@ class TypingHappyPathTestPMs(ZulipTestCase):
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        with queries_captured() as queries:
 | 
			
		||||
            with self.tornado_redirected_to_list(events):
 | 
			
		||||
            with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
                result = self.api_post(sender, "/api/v1/typing", params)
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
        self.assert_length(events, 1)
 | 
			
		||||
@@ -219,7 +219,7 @@ class TypingHappyPathTestPMs(ZulipTestCase):
 | 
			
		||||
        expected_recipient_emails = {email}
 | 
			
		||||
        expected_recipient_ids = {user.id}
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.api_post(
 | 
			
		||||
                user,
 | 
			
		||||
                "/api/v1/typing",
 | 
			
		||||
@@ -260,7 +260,7 @@ class TypingHappyPathTestPMs(ZulipTestCase):
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.api_post(sender, "/api/v1/typing", params)
 | 
			
		||||
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
@@ -289,7 +289,7 @@ class TypingHappyPathTestPMs(ZulipTestCase):
 | 
			
		||||
        expected_recipient_ids = {user.id}
 | 
			
		||||
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            params = dict(
 | 
			
		||||
                to=orjson.dumps([user.id]).decode(),
 | 
			
		||||
                op="stop",
 | 
			
		||||
@@ -323,7 +323,7 @@ class TypingHappyPathTestPMs(ZulipTestCase):
 | 
			
		||||
        expected_recipient_ids = {user.id for user in expected_recipients}
 | 
			
		||||
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            params = dict(
 | 
			
		||||
                to=orjson.dumps([recipient.id]).decode(),
 | 
			
		||||
                op="stop",
 | 
			
		||||
@@ -367,7 +367,7 @@ class TypingHappyPathTestStreams(ZulipTestCase):
 | 
			
		||||
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with queries_captured() as queries:
 | 
			
		||||
            with self.tornado_redirected_to_list(events):
 | 
			
		||||
            with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
                result = self.api_post(sender, "/api/v1/typing", params)
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
        self.assert_length(events, 1)
 | 
			
		||||
@@ -403,7 +403,7 @@ class TypingHappyPathTestStreams(ZulipTestCase):
 | 
			
		||||
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with queries_captured() as queries:
 | 
			
		||||
            with self.tornado_redirected_to_list(events):
 | 
			
		||||
            with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
                result = self.api_post(sender, "/api/v1/typing", params)
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
        self.assert_length(events, 1)
 | 
			
		||||
 
 | 
			
		||||
@@ -142,7 +142,7 @@ class UserStatusTest(ZulipTestCase):
 | 
			
		||||
        self, payload: Dict[str, Any], expected_event: Dict[str, Any]
 | 
			
		||||
    ) -> None:
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.client_post("/json/users/me/status", payload)
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
        self.assertEqual(events[0]["event"], expected_event)
 | 
			
		||||
 
 | 
			
		||||
@@ -184,7 +184,7 @@ class PermissionTest(ZulipTestCase):
 | 
			
		||||
 | 
			
		||||
        req = dict(role=UserProfile.ROLE_REALM_OWNER)
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.client_patch(f"/json/users/{othello.id}", req)
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
        owner_users = realm.get_human_owner_users()
 | 
			
		||||
@@ -195,7 +195,7 @@ class PermissionTest(ZulipTestCase):
 | 
			
		||||
 | 
			
		||||
        req = dict(role=UserProfile.ROLE_MEMBER)
 | 
			
		||||
        events = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.client_patch(f"/json/users/{othello.id}", req)
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
        owner_users = realm.get_human_owner_users()
 | 
			
		||||
@@ -208,7 +208,7 @@ class PermissionTest(ZulipTestCase):
 | 
			
		||||
        self.login("desdemona")
 | 
			
		||||
        req = dict(role=UserProfile.ROLE_MEMBER)
 | 
			
		||||
        events = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.client_patch(f"/json/users/{iago.id}", req)
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
        owner_users = realm.get_human_owner_users()
 | 
			
		||||
@@ -249,7 +249,7 @@ class PermissionTest(ZulipTestCase):
 | 
			
		||||
        req = dict(role=orjson.dumps(UserProfile.ROLE_REALM_ADMINISTRATOR).decode())
 | 
			
		||||
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.client_patch(f"/json/users/{othello.id}", req)
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
        admin_users = realm.get_human_admin_users()
 | 
			
		||||
@@ -261,7 +261,7 @@ class PermissionTest(ZulipTestCase):
 | 
			
		||||
        # Taketh away
 | 
			
		||||
        req = dict(role=orjson.dumps(UserProfile.ROLE_MEMBER).decode())
 | 
			
		||||
        events = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.client_patch(f"/json/users/{othello.id}", req)
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
        admin_users = realm.get_human_admin_users()
 | 
			
		||||
@@ -497,7 +497,7 @@ class PermissionTest(ZulipTestCase):
 | 
			
		||||
 | 
			
		||||
        req = dict(role=orjson.dumps(new_role).decode())
 | 
			
		||||
        events: List[Mapping[str, Any]] = []
 | 
			
		||||
        with self.tornado_redirected_to_list(events):
 | 
			
		||||
        with self.tornado_redirected_to_list(events, expected_num_events=1):
 | 
			
		||||
            result = self.client_patch(f"/json/users/{user_profile.id}", req)
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user