diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index b67c921ea5..6c8e5a7039 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -617,7 +617,7 @@ class NormalActionsTest(BaseAction): do_change_subscription_property(hamlet, sub, stream, "is_muted", True, acting_user=None) def verify_events_generated_and_reset_visibility_policy( - events: List[Dict[str, Any]], stream_name: str, topic: str + events: List[Dict[str, Any]], stream_name: str, topic_name: str ) -> None: # event-type: muted_topics check_muted_topics("events[0]", events[0]) @@ -634,7 +634,7 @@ class NormalActionsTest(BaseAction): do_set_user_topic_visibility_policy( hamlet, get_stream(stream_name, hamlet.realm), - topic, + topic_name, visibility_policy=UserTopic.VisibilityPolicy.INHERIT, ) @@ -874,7 +874,7 @@ class NormalActionsTest(BaseAction): ) # Verify stream message editing - topic only - topic = "new_topic" + topic_name = "new_topic" propagate_mode = "change_all" events = self.verify_action( @@ -882,7 +882,7 @@ class NormalActionsTest(BaseAction): self.user_profile, message, None, - topic, + topic_name, propagate_mode, False, False, @@ -1319,14 +1319,14 @@ class NormalActionsTest(BaseAction): def test_stream_typing_events(self) -> None: stream = get_stream("Denmark", self.user_profile.realm) - topic = "streams typing" + topic_name = "streams typing" events = self.verify_action( lambda: do_send_stream_typing_notification( self.user_profile, "start", stream, - topic, + topic_name, ), state_change_expected=False, ) @@ -1337,7 +1337,7 @@ class NormalActionsTest(BaseAction): self.user_profile, "stop", stream, - topic, + topic_name, ), state_change_expected=False, ) @@ -1350,7 +1350,7 @@ class NormalActionsTest(BaseAction): self.user_profile, "start", stream, - topic, + topic_name, ), state_change_expected=False, stream_typing_notifications=False, @@ -1363,7 +1363,7 @@ class NormalActionsTest(BaseAction): self.user_profile, "stop", stream, - topic, + topic_name, ), state_change_expected=False, stream_typing_notifications=False, diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py index 868d59da70..b3dd3a539f 100644 --- a/zerver/tests/test_home.py +++ b/zerver/tests/test_home.py @@ -1096,9 +1096,9 @@ class HomeTest(ZulipTestCase): return self.send_stream_message(sender, stream_name, content=content, topic_name=topic_name) def soft_activate_and_get_unread_count( - self, stream: str = "Denmark", topic: str = "foo" + self, stream: str = "Denmark", topic_name: str = "foo" ) -> int: - stream_narrow = self._get_home_page(stream=stream, topic=topic) + stream_narrow = self._get_home_page(stream=stream, topic=topic_name) page_params = self._get_page_params(stream_narrow) return page_params["unread_msgs"]["count"] diff --git a/zerver/tests/test_import_export.py b/zerver/tests/test_import_export.py index adef08fd51..4b73f734aa 100644 --- a/zerver/tests/test_import_export.py +++ b/zerver/tests/test_import_export.py @@ -1281,8 +1281,8 @@ class RealmImportExportTest(ExportFile): @getter def get_stream_topics(r: Realm) -> Set[str]: messages = get_stream_messages(r) - topics = {m.topic_name() for m in messages} - return topics + topic_names = {m.topic_name() for m in messages} + return topic_names # test usermessages @getter diff --git a/zerver/tests/test_message_edit.py b/zerver/tests/test_message_edit.py index 9fbc13ab1d..1ce1e8cacf 100644 --- a/zerver/tests/test_message_edit.py +++ b/zerver/tests/test_message_edit.py @@ -99,7 +99,7 @@ class EditMessageTestCase(ZulipTestCase): user_email: str, old_stream: str, new_stream: str, - topic: str, + topic_name: str, language: Optional[str] = None, ) -> Tuple[UserProfile, Stream, Stream, int, int]: user_profile = self.example_user(user_email) @@ -113,13 +113,13 @@ class EditMessageTestCase(ZulipTestCase): self.subscribe(user_profile, stream.name) self.subscribe(user_profile, stream_to.name) msg_id = self.send_stream_message( - user_profile, stream.name, topic_name=topic, content="First" + user_profile, stream.name, topic_name=topic_name, content="First" ) msg_id_lt = self.send_stream_message( - user_profile, stream.name, topic_name=topic, content="Second" + user_profile, stream.name, topic_name=topic_name, content="Second" ) - self.send_stream_message(user_profile, stream.name, topic_name=topic, content="third") + self.send_stream_message(user_profile, stream.name, topic_name=topic_name, content="third") return (user_profile, stream, stream_to, msg_id, msg_id_lt) @@ -1064,27 +1064,27 @@ class EditMessageTest(EditMessageTestCase): def do_edit_message_assert_success( id_: int, unique_str: str, topic_only: bool = False ) -> None: - new_topic = "topic" + unique_str + new_topic_name = "topic" + unique_str new_content = "content" + unique_str - params_dict = {"topic": new_topic} + params_dict = {"topic": new_topic_name} if not topic_only: params_dict["content"] = new_content result = self.client_patch(f"/json/messages/{id_}", params_dict) self.assert_json_success(result) if topic_only: - self.check_topic(id_, topic_name=new_topic) + self.check_topic(id_, topic_name=new_topic_name) else: - self.check_message(id_, topic_name=new_topic, content=new_content) + self.check_message(id_, topic_name=new_topic_name, content=new_content) def do_edit_message_assert_error( id_: int, unique_str: str, error: str, topic_only: bool = False ) -> None: message = Message.objects.get(id=id_) - old_topic = message.topic_name() + old_topic_name = message.topic_name() old_content = message.content - new_topic = "topic" + unique_str + new_topic_name = "topic" + unique_str new_content = "content" + unique_str - params_dict = {"topic": new_topic} + params_dict = {"topic": new_topic_name} if not topic_only: params_dict["content"] = new_content result = self.client_patch(f"/json/messages/{id_}", params_dict) @@ -1092,7 +1092,7 @@ class EditMessageTest(EditMessageTestCase): self.assert_json_error(result, error) msg = Message.objects.get(id=id_) - self.assertEqual(msg.topic_name(), old_topic) + self.assertEqual(msg.topic_name(), old_topic_name) self.assertEqual(msg.content, old_content) self.login("iago") @@ -1152,26 +1152,26 @@ class EditMessageTest(EditMessageTestCase): def do_edit_message_assert_success(id_: int, unique_str: str, acting_user: str) -> None: self.login(acting_user) - new_topic = "topic" + unique_str - params_dict = {"topic": new_topic} + new_topic_name = "topic" + unique_str + params_dict = {"topic": new_topic_name} result = self.client_patch(f"/json/messages/{id_}", params_dict) self.assert_json_success(result) - self.check_topic(id_, topic_name=new_topic) + self.check_topic(id_, topic_name=new_topic_name) def do_edit_message_assert_error( id_: int, unique_str: str, error: str, acting_user: str ) -> None: self.login(acting_user) message = Message.objects.get(id=id_) - old_topic = message.topic_name() + old_topic_name = message.topic_name() old_content = message.content - new_topic = "topic" + unique_str - params_dict = {"topic": new_topic} + new_topic_name = "topic" + unique_str + params_dict = {"topic": new_topic_name} result = self.client_patch(f"/json/messages/{id_}", params_dict) message = Message.objects.get(id=id_) self.assert_json_error(result, error) msg = Message.objects.get(id=id_) - self.assertEqual(msg.topic_name(), old_topic) + self.assertEqual(msg.topic_name(), old_topic_name) self.assertEqual(msg.content, old_content) # send a message in the past @@ -1406,11 +1406,11 @@ class EditMessageTest(EditMessageTestCase): ) ) - already_muted_topic = "Already muted topic" + already_muted_topic_name = "Already muted topic" muted_topics = [ [stream_name, "Topic1"], [stream_name, "Topic2"], - [stream_name, already_muted_topic], + [stream_name, already_muted_topic_name], ] set_topic_visibility_policy(hamlet, muted_topics, UserTopic.VisibilityPolicy.MUTED) set_topic_visibility_policy(cordelia, muted_topics, UserTopic.VisibilityPolicy.MUTED) @@ -1493,14 +1493,14 @@ class EditMessageTest(EditMessageTestCase): user_profile=hamlet, message_id=message_id, stream_id=None, - topic_name=already_muted_topic, + topic_name=already_muted_topic_name, propagate_mode="change_all", send_notification_to_old_thread=False, send_notification_to_new_thread=False, content=None, ) assert_is_topic_muted(hamlet, stream.id, change_later_topic_name, muted=False) - assert_is_topic_muted(hamlet, stream.id, already_muted_topic, muted=True) + assert_is_topic_muted(hamlet, stream.id, already_muted_topic_name, muted=True) change_one_topic_name = "Topic 1 edited change_one" check_update_message( @@ -2576,12 +2576,12 @@ class EditMessageTest(EditMessageTestCase): id4 = self.send_stream_message(self.example_user("hamlet"), "Denmark", topic_name="topic2") id5 = self.send_stream_message(self.example_user("iago"), "Denmark", topic_name="topic1") - def verify_edit_history(new_topic: str, len_edit_history: int) -> None: + def verify_edit_history(new_topic_name: str, len_edit_history: int) -> None: for msg_id in [id1, id2, id5]: msg = Message.objects.get(id=msg_id) self.assertEqual( - new_topic, + new_topic_name, msg.topic_name(), ) # Since edit history is being generated by do_update_message, @@ -2595,29 +2595,29 @@ class EditMessageTest(EditMessageTestCase): msg = Message.objects.get(id=msg_id) self.assertEqual(msg.edit_history, None) - new_topic = "edited" + new_topic_name = "edited" result = self.client_patch( f"/json/messages/{id1}", { - "topic": new_topic, + "topic": new_topic_name, "propagate_mode": "change_later", }, ) self.assert_json_success(result) - verify_edit_history(new_topic, 1) + verify_edit_history(new_topic_name, 1) - new_topic = "edited2" + new_topic_name = "edited2" result = self.client_patch( f"/json/messages/{id1}", { - "topic": new_topic, + "topic": new_topic_name, "propagate_mode": "change_later", }, ) self.assert_json_success(result) - verify_edit_history(new_topic, 2) + verify_edit_history(new_topic_name, 2) def test_topic_and_content_edit(self) -> None: self.login("hamlet") @@ -2625,11 +2625,11 @@ class EditMessageTest(EditMessageTestCase): id2 = self.send_stream_message(self.example_user("iago"), "Denmark", "message 2", "topic") id3 = self.send_stream_message(self.example_user("hamlet"), "Denmark", "message 3", "topic") - new_topic = "edited" + new_topic_name = "edited" result = self.client_patch( "/json/messages/" + str(id1), { - "topic": new_topic, + "topic": new_topic_name, "propagate_mode": "change_later", "content": "edited message", }, @@ -2653,7 +2653,7 @@ class EditMessageTest(EditMessageTestCase): for msg in [msg1, msg2, msg3]: self.assertEqual( - new_topic, + new_topic_name, msg.topic_name(), ) self.assert_length(orjson.loads(assert_is_not_none(msg.edit_history)), 1) @@ -2756,11 +2756,11 @@ class EditMessageTest(EditMessageTestCase): verona = get_stream("Verona", user_profile.realm) denmark = get_stream("Denmark", user_profile.realm) - old_topic = "topic1" + old_topic_name = "topic1" old_stream = denmark def test_moving_all_topic_messages( - new_topic: Optional[str] = None, new_stream: Optional[Stream] = None + new_topic_name: Optional[str] = None, new_stream: Optional[Stream] = None ) -> None: self.login("hamlet") params_dict: Dict[str, Union[str, int]] = { @@ -2768,10 +2768,10 @@ class EditMessageTest(EditMessageTestCase): "send_notification_to_new_thread": "false", } - if new_topic is not None: - params_dict["topic"] = new_topic + if new_topic_name is not None: + params_dict["topic"] = new_topic_name else: - new_topic = old_topic + new_topic_name = old_topic_name if new_stream is not None: params_dict["stream_id"] = new_stream.id @@ -2787,11 +2787,11 @@ class EditMessageTest(EditMessageTestCase): "You only have permission to move the 3/5 most recent messages in this topic.", ) # Check message count in old topic and/or stream. - messages = get_topic_messages(user_profile, old_stream, old_topic) + messages = get_topic_messages(user_profile, old_stream, old_topic_name) self.assert_length(messages, 5) # Check message count in new topic and/or stream. - messages = get_topic_messages(user_profile, new_stream, new_topic) + messages = get_topic_messages(user_profile, new_stream, new_topic_name) self.assert_length(messages, 0) json = orjson.loads(result.content) @@ -2805,11 +2805,11 @@ class EditMessageTest(EditMessageTestCase): self.assert_json_success(result) # Check message count in old topic and/or stream. - messages = get_topic_messages(user_profile, old_stream, old_topic) + messages = get_topic_messages(user_profile, old_stream, old_topic_name) self.assert_length(messages, 2) # Check message count in new topic and/or stream. - messages = get_topic_messages(user_profile, new_stream, new_topic) + messages = get_topic_messages(user_profile, new_stream, new_topic_name) self.assert_length(messages, 3) self.login("shiva") @@ -2818,7 +2818,7 @@ class EditMessageTest(EditMessageTestCase): result = self.client_patch( f"/json/messages/{id4}", { - "topic": old_topic, + "topic": old_topic_name, "stream_id": old_stream.id, "propagate_mode": "change_all", "send_notification_to_new_thread": "false", @@ -2833,21 +2833,21 @@ class EditMessageTest(EditMessageTestCase): self.assert_json_success(result) # Check message count in old topic and/or stream. - messages = get_topic_messages(user_profile, old_stream, old_topic) + messages = get_topic_messages(user_profile, old_stream, old_topic_name) self.assert_length(messages, 0) # Check message count in new topic and/or stream. - messages = get_topic_messages(user_profile, new_stream, new_topic) + messages = get_topic_messages(user_profile, new_stream, new_topic_name) self.assert_length(messages, 5) # Test only topic editing case. - test_moving_all_topic_messages(new_topic="topic edited") + test_moving_all_topic_messages(new_topic_name="topic edited") # Move these messages to the original topic to test the next case. self.client_patch( f"/json/messages/{id4}", { - "topic": old_topic, + "topic": old_topic_name, "propagate_mode": "change_all", "send_notification_to_new_thread": "false", }, @@ -2875,14 +2875,14 @@ class EditMessageTest(EditMessageTestCase): ) # Test editing both topic and stream together. - test_moving_all_topic_messages(new_topic="edited", new_stream=verona) + test_moving_all_topic_messages(new_topic_name="edited", new_stream=verona) # Move these messages to the original stream and topic to test the next case. self.client_patch( f"/json/messages/{id4}", { "stream_id": denmark.id, - "topic": old_topic, + "topic": old_topic_name, "propagate_mode": "change_all", "send_notification_to_new_thread": "false", }, @@ -2904,11 +2904,11 @@ class EditMessageTest(EditMessageTestCase): ) new_stream = verona - new_topic = "edited" + new_topic_name = "edited" result = self.client_patch( f"/json/messages/{id4}", { - "topic": new_topic, + "topic": new_topic_name, "stream_id": new_stream.id, "propagate_mode": "change_all", "send_notification_to_new_thread": "false", @@ -2916,11 +2916,11 @@ class EditMessageTest(EditMessageTestCase): ) self.assert_json_success(result) # Check message count in old topic and/or stream. - messages = get_topic_messages(user_profile, old_stream, old_topic) + messages = get_topic_messages(user_profile, old_stream, old_topic_name) self.assert_length(messages, 0) # Check message count in new topic and/or stream. - messages = get_topic_messages(user_profile, new_stream, new_topic) + messages = get_topic_messages(user_profile, new_stream, new_topic_name) self.assert_length(messages, 5) def test_change_all_propagate_mode_for_moving_from_stream_with_restricted_history(self) -> None: @@ -4346,22 +4346,22 @@ class EditMessageTest(EditMessageTestCase): user_profile = self.example_user("hamlet") self.login("hamlet") stream = self.make_stream("public stream") - topic = "test" + topic_name = "test" self.subscribe(user_profile, stream.name) # Resolve a topic normally first - msg_id = self.send_stream_message(user_profile, stream.name, "foo", topic_name=topic) - resolved_topic = RESOLVED_TOPIC_PREFIX + topic + msg_id = self.send_stream_message(user_profile, stream.name, "foo", topic_name=topic_name) + resolved_topic_name = RESOLVED_TOPIC_PREFIX + topic_name result = self.client_patch( "/json/messages/" + str(msg_id), { - "topic": resolved_topic, + "topic": resolved_topic_name, "propagate_mode": "change_all", }, ) self.assert_json_success(result) - messages = get_topic_messages(user_profile, stream, resolved_topic) + messages = get_topic_messages(user_profile, stream, resolved_topic_name) self.assert_length(messages, 2) self.assertEqual( messages[1].content, @@ -4369,16 +4369,16 @@ class EditMessageTest(EditMessageTestCase): ) # Test unresolving a topic while moving it (✔ test -> bar) - new_topic = "bar" + new_topic_name = "bar" result = self.client_patch( "/json/messages/" + str(msg_id), { - "topic": new_topic, + "topic": new_topic_name, "propagate_mode": "change_all", }, ) self.assert_json_success(result) - messages = get_topic_messages(user_profile, stream, new_topic) + messages = get_topic_messages(user_profile, stream, new_topic_name) self.assert_length(messages, 4) self.assertEqual( messages[2].content, @@ -4390,16 +4390,16 @@ class EditMessageTest(EditMessageTestCase): ) # Now test moving the topic while also resolving it (bar -> ✔ baz) - new_resolved_topic = RESOLVED_TOPIC_PREFIX + "baz" + new_resolved_topic_name = RESOLVED_TOPIC_PREFIX + "baz" result = self.client_patch( "/json/messages/" + str(msg_id), { - "topic": new_resolved_topic, + "topic": new_resolved_topic_name, "propagate_mode": "change_all", }, ) self.assert_json_success(result) - messages = get_topic_messages(user_profile, stream, new_resolved_topic) + messages = get_topic_messages(user_profile, stream, new_resolved_topic_name) self.assert_length(messages, 6) self.assertEqual( messages[4].content, @@ -4407,7 +4407,7 @@ class EditMessageTest(EditMessageTestCase): ) self.assertEqual( messages[5].content, - f"This topic was moved here from #**public stream>{new_topic}** by @_**{user_profile.full_name}|{user_profile.id}**.", + f"This topic was moved here from #**public stream>{new_topic_name}** by @_**{user_profile.full_name}|{user_profile.id}**.", ) def test_notify_resolve_topic_and_move_stream(self) -> None: @@ -4424,18 +4424,18 @@ class EditMessageTest(EditMessageTestCase): self.assert_length(messages, 3) # Test resolving a topic (test -> ✔ test) while changing stream (first_stream -> second_stream) - new_topic = "✔ test" + new_topic_name = "✔ test" new_stream = second_stream result = self.client_patch( "/json/messages/" + str(msg_id), { "stream_id": new_stream.id, - "topic": new_topic, + "topic": new_topic_name, "propagate_mode": "change_all", }, ) self.assert_json_success(result) - messages = get_topic_messages(user_profile, new_stream, new_topic) + messages = get_topic_messages(user_profile, new_stream, new_topic_name) self.assert_length(messages, 5) self.assertEqual( messages[3].content, @@ -4447,18 +4447,18 @@ class EditMessageTest(EditMessageTestCase): ) # Test unresolving a topic (✔ test -> test) while changing stream (second_stream -> first_stream) - new_topic = "test" + new_topic_name = "test" new_stream = first_stream result = self.client_patch( "/json/messages/" + str(msg_id), { "stream_id": new_stream.id, - "topic": new_topic, + "topic": new_topic_name, "propagate_mode": "change_all", }, ) self.assert_json_success(result) - messages = get_topic_messages(user_profile, new_stream, new_topic) + messages = get_topic_messages(user_profile, new_stream, new_topic_name) self.assert_length(messages, 7) self.assertEqual( messages[5].content, @@ -4605,9 +4605,9 @@ class EditMessageTest(EditMessageTestCase): self.subscribe(cordelia, stream.name) self.subscribe(aaron, stream.name) - original_topic = "topic 1" - id1 = self.send_stream_message(hamlet, "new", topic_name=original_topic) - id2 = self.send_stream_message(admin_user, "new", topic_name=original_topic) + original_topic_name = "topic 1" + id1 = self.send_stream_message(hamlet, "new", topic_name=original_topic_name) + id2 = self.send_stream_message(admin_user, "new", topic_name=original_topic_name) msg1 = Message.objects.get(id=id1) do_add_reaction(aaron, msg1, "tada", "1f389", "unicode_emoji") @@ -4617,13 +4617,13 @@ class EditMessageTest(EditMessageTestCase): result = self.client_patch( "/json/messages/" + str(id1), { - "topic": original_topic, + "topic": original_topic_name, "propagate_mode": "change_all", }, ) self.assert_json_error(result, "Nothing to change") - resolved_topic = RESOLVED_TOPIC_PREFIX + original_topic + resolved_topic_name = RESOLVED_TOPIC_PREFIX + original_topic_name result = self.resolve_topic_containing_message( admin_user, id1, @@ -4634,11 +4634,11 @@ class EditMessageTest(EditMessageTestCase): for msg_id in [id1, id2]: msg = Message.objects.get(id=msg_id) self.assertEqual( - resolved_topic, + resolved_topic_name, msg.topic_name(), ) - messages = get_topic_messages(admin_user, stream, resolved_topic) + messages = get_topic_messages(admin_user, stream, resolved_topic_name) self.assert_length(messages, 3) self.assertEqual( messages[2].content, @@ -4662,11 +4662,11 @@ class EditMessageTest(EditMessageTestCase): ) # Now move to a weird state and confirm we get the normal topic moved message. - weird_topic = "✔ ✔✔" + original_topic + weird_topic_name = "✔ ✔✔" + original_topic_name result = self.client_patch( "/json/messages/" + str(id1), { - "topic": weird_topic, + "topic": weird_topic_name, "propagate_mode": "change_all", }, ) @@ -4675,11 +4675,11 @@ class EditMessageTest(EditMessageTestCase): for msg_id in [id1, id2]: msg = Message.objects.get(id=msg_id) self.assertEqual( - weird_topic, + weird_topic_name, msg.topic_name(), ) - messages = get_topic_messages(admin_user, stream, weird_topic) + messages = get_topic_messages(admin_user, stream, weird_topic_name) self.assert_length(messages, 4) self.assertEqual( messages[2].content, @@ -4690,11 +4690,11 @@ class EditMessageTest(EditMessageTestCase): f"This topic was moved here from #**new>✔ topic 1** by @_**Iago|{admin_user.id}**.", ) - unresolved_topic = original_topic + unresolved_topic_name = original_topic_name result = self.client_patch( "/json/messages/" + str(id1), { - "topic": unresolved_topic, + "topic": unresolved_topic_name, "propagate_mode": "change_all", }, ) @@ -4703,11 +4703,11 @@ class EditMessageTest(EditMessageTestCase): for msg_id in [id1, id2]: msg = Message.objects.get(id=msg_id) self.assertEqual( - unresolved_topic, + unresolved_topic_name, msg.topic_name(), ) - messages = get_topic_messages(admin_user, stream, unresolved_topic) + messages = get_topic_messages(admin_user, stream, unresolved_topic_name) self.assert_length(messages, 5) self.assertEqual( messages[2].content, f"@_**Iago|{admin_user.id}** has marked this topic as resolved." diff --git a/zerver/tests/test_message_send.py b/zerver/tests/test_message_send.py index 393d367173..9bb8019bb7 100644 --- a/zerver/tests/test_message_send.py +++ b/zerver/tests/test_message_send.py @@ -1138,12 +1138,12 @@ class MessagePOSTTest(ZulipTestCase): succeeds, but the topic is truncated. """ self.login("hamlet") - long_topic = "A" * (MAX_TOPIC_NAME_LENGTH + 1) + long_topic_name = "A" * (MAX_TOPIC_NAME_LENGTH + 1) post_data = { "type": "stream", "to": orjson.dumps("Verona").decode(), "content": "test content", - "topic": long_topic, + "topic": long_topic_name, } result = self.client_post("/json/messages", post_data) self.assert_json_success(result) diff --git a/zerver/tests/test_message_topics.py b/zerver/tests/test_message_topics.py index a9f0b714b2..a47ba5aae3 100644 --- a/zerver/tests/test_message_topics.py +++ b/zerver/tests/test_message_topics.py @@ -40,7 +40,7 @@ class TopicHistoryTest(ZulipTestCase): stream = get_stream(stream_name, user_profile.realm) recipient = stream.recipient - def create_test_message(topic: str) -> int: + def create_test_message(topic_name: str) -> int: # TODO: Clean this up to send messages the normal way. hamlet = self.example_user("hamlet") @@ -52,7 +52,7 @@ class TopicHistoryTest(ZulipTestCase): date_sent=timezone_now(), sending_client=get_client("whatever"), ) - message.set_topic_name(topic) + message.set_topic_name(topic_name) message.save() UserMessage.objects.create( diff --git a/zerver/tests/test_typing.py b/zerver/tests/test_typing.py index ca01c2bf67..4400ba1f8b 100644 --- a/zerver/tests/test_typing.py +++ b/zerver/tests/test_typing.py @@ -133,7 +133,7 @@ class TypingValidateStreamIdTopicArgumentsTest(ZulipTestCase): def test_stream_doesnt_exist(self) -> None: sender = self.example_user("hamlet") stream_id = self.INVALID_STREAM_ID - topic = "some topic" + topic_name = "some topic" result = self.api_post( sender, @@ -142,7 +142,7 @@ class TypingValidateStreamIdTopicArgumentsTest(ZulipTestCase): "type": "stream", "op": "start", "stream_id": str(stream_id), - "topic": topic, + "topic": topic_name, }, ) self.assert_json_error(result, "Invalid stream ID") @@ -371,7 +371,7 @@ class TypingHappyPathTestStreams(ZulipTestCase): sender = self.example_user("hamlet") stream_name = self.get_streams(sender)[0] stream_id = self.get_stream_id(stream_name) - topic = "Some topic" + topic_name = "Some topic" expected_user_ids = self.not_long_term_idle_subscriber_ids(stream_name, sender.realm) @@ -379,7 +379,7 @@ class TypingHappyPathTestStreams(ZulipTestCase): type="stream", op="start", stream_id=str(stream_id), - topic=topic, + topic=topic_name, ) with self.assert_database_query_count(6): @@ -394,7 +394,7 @@ class TypingHappyPathTestStreams(ZulipTestCase): self.assertEqual(expected_user_ids, event_user_ids) self.assertEqual(sender.email, event["sender"]["email"]) self.assertEqual(stream_id, event["stream_id"]) - self.assertEqual(topic, event["topic"]) + self.assertEqual(topic_name, event["topic"]) self.assertEqual("typing", event["type"]) self.assertEqual("start", event["op"]) @@ -402,7 +402,7 @@ class TypingHappyPathTestStreams(ZulipTestCase): sender = self.example_user("hamlet") stream_name = self.get_streams(sender)[0] stream_id = self.get_stream_id(stream_name) - topic = "Some topic" + topic_name = "Some topic" expected_user_ids = self.not_long_term_idle_subscriber_ids(stream_name, sender.realm) @@ -410,7 +410,7 @@ class TypingHappyPathTestStreams(ZulipTestCase): type="stream", op="stop", stream_id=str(stream_id), - topic=topic, + topic=topic_name, ) with self.assert_database_query_count(6): @@ -425,7 +425,7 @@ class TypingHappyPathTestStreams(ZulipTestCase): self.assertEqual(expected_user_ids, event_user_ids) self.assertEqual(sender.email, event["sender"]["email"]) self.assertEqual(stream_id, event["stream_id"]) - self.assertEqual(topic, event["topic"]) + self.assertEqual(topic_name, event["topic"]) self.assertEqual("typing", event["type"]) self.assertEqual("stop", event["op"]) @@ -433,7 +433,7 @@ class TypingHappyPathTestStreams(ZulipTestCase): sender = self.example_user("hamlet") stream_name = self.get_streams(sender)[0] stream_id = self.get_stream_id(stream_name) - topic = "Some topic" + topic_name = "Some topic" for name in ["aaron", "iago", "cordelia", "prospero", "othello", "polonius"]: user = self.example_user(name) @@ -443,7 +443,7 @@ class TypingHappyPathTestStreams(ZulipTestCase): type="stream", op="start", stream_id=str(stream_id), - topic=topic, + topic=topic_name, ) with self.settings(MAX_STREAM_SIZE_FOR_TYPING_NOTIFICATIONS=5): with self.assert_database_query_count(5): @@ -456,7 +456,7 @@ class TypingHappyPathTestStreams(ZulipTestCase): sender = self.example_user("hamlet") stream_name = self.get_streams(sender)[0] stream_id = self.get_stream_id(stream_name) - topic = "Some topic" + topic_name = "Some topic" aaron = self.example_user("aaron") iago = self.example_user("iago") @@ -474,7 +474,7 @@ class TypingHappyPathTestStreams(ZulipTestCase): type="stream", op="start", stream_id=str(stream_id), - topic=topic, + topic=topic_name, ) with self.assert_database_query_count(6): @@ -492,7 +492,7 @@ class TypingHappyPathTestStreams(ZulipTestCase): self.assertEqual(sender.email, event["sender"]["email"]) self.assertEqual(stream_id, event["stream_id"]) - self.assertEqual(topic, event["topic"]) + self.assertEqual(topic_name, event["topic"]) self.assertEqual("typing", event["type"]) self.assertEqual("start", event["op"]) @@ -535,7 +535,7 @@ class TestSendTypingNotificationsSettings(ZulipTestCase): sender = self.example_user("hamlet") stream_name = self.get_streams(sender)[0] stream_id = self.get_stream_id(stream_name) - topic = "Some topic" + topic_name = "Some topic" expected_user_ids = self.not_long_term_idle_subscriber_ids(stream_name, sender.realm) @@ -543,7 +543,7 @@ class TestSendTypingNotificationsSettings(ZulipTestCase): type="stream", op="start", stream_id=str(stream_id), - topic=topic, + topic=topic_name, ) # Test typing events sent when `send_stream_typing_notifications` set to `True`. diff --git a/zerver/tests/test_webhooks_common.py b/zerver/tests/test_webhooks_common.py index f4d55e2a33..675e7882a7 100644 --- a/zerver/tests/test_webhooks_common.py +++ b/zerver/tests/test_webhooks_common.py @@ -169,14 +169,14 @@ class WebhookURLConfigurationTestCase(WebhookTestCase): self.test_user, self.url, payload, content_type="application/json" ) - expected_topic = "Hello World" + expected_topic_name = "Hello World" expected_message = "Hello! I am happy to be here! :smile:\nThe Wikipedia featured article for today is **[Marilyn Monroe](https://en.wikipedia.org/wiki/Marilyn_Monroe)**" msg = self.get_last_message() self.assert_stream_message( message=msg, stream_name="helloworld_renamed", - topic_name=expected_topic, + topic_name=expected_topic_name, content=expected_message, )