diff --git a/docs/developer-feature-tutorial.md b/docs/developer-feature-tutorial.md index 70c4e62cdb..e0e41a2f9c 100644 --- a/docs/developer-feature-tutorial.md +++ b/docs/developer-feature-tutorial.md @@ -115,7 +115,7 @@ To check for the above conditions, we create a function in `ui.py`: def handle_typing_event(self, event: Dict['str', Any]) -> None: # If the user is in dm narrow with the person typing if len(self.model.narrow) == 1 and\ - self.model.narrow[0][0] == 'pm_with' and\ + self.model.narrow[0][0] == 'dm_with' and\ event['sender']['email'] in self.model.narrow[0][1].split(','): if event['op'] == 'start': user = self.model.user_dict[event['sender']['email']] diff --git a/tests/conftest.py b/tests/conftest.py index fe17dd0ed2..5b4b38377f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -500,7 +500,7 @@ def extra_stream_msg_template() -> Message: @pytest.fixture -def pm_template() -> Message: +def dm_template() -> Message: recipients = display_recipient_factory([(5179, "Boo Boo"), (5140, "Foo Foo")]) return msg_template_factory(537287, "private", 1520918736, recipients=recipients) @@ -513,18 +513,18 @@ def group_dm_template() -> Message: return msg_template_factory(537288, "private", 1520918737, recipients=recipients) -@pytest.fixture(params=["pm_template", "group_dm_template"]) +@pytest.fixture(params=["dm_template", "group_dm_template"]) def direct_message_fixture(request: Any) -> Message: return request.getfixturevalue(request.param) @pytest.fixture( - params=["stream_msg_template", "pm_template", "group_dm_template"], - ids=["stream_message", "pm_message", "group_pm_message"], + params=["stream_msg_template", "dm_template", "group_dm_template"], + ids=["stream_message", "dm_message", "group_dm_message"], ) def message_fixture(request: Any) -> Message: """ - Acts as a parametrize fixture for stream msg, dms and group_pms. + Acts as a parametrize fixture for stream msg, dms and group_dms. """ # `request` currently does not have an exported Pytest type. # TODO: Use the exported type when it's made available. @@ -535,7 +535,7 @@ def message_fixture(request: Any) -> Message: @pytest.fixture def messages_successful_response( stream_msg_template: Message, - pm_template: Message, + dm_template: Message, group_dm_template: Message, ) -> Dict[str, Any]: """ @@ -546,7 +546,7 @@ def messages_successful_response( "anchor": 10000000000000000, "messages": [ stream_msg_template, - pm_template, + dm_template, group_dm_template, ], "result": "success", @@ -634,10 +634,10 @@ def topics() -> List[str]: ], ids=[ "stream_mention__stream_wildcard", - "stream+pm_mention__no_wildcard", - "no_mention__stream+pm_wildcard", - "stream+group_mention__pm_wildcard", - "pm_mention__stream+group_wildcard", + "stream+dm_mention__no_wildcard", + "no_mention__stream+dm_wildcard", + "stream+group_mention__dm_wildcard", + "dm_mention__stream+group_wildcard", "group_mention__all_wildcard", "all_mention__stream_wildcard", "stream+group_mention__wildcard", @@ -1060,7 +1060,7 @@ def initial_index() -> Index: @pytest.fixture def empty_index( - stream_msg_template: Message, pm_template: Message, group_dm_template: Message + stream_msg_template: Message, dm_template: Message, group_dm_template: Message ) -> Index: return deepcopy( Index( @@ -1079,7 +1079,7 @@ def empty_index( lambda: {}, { stream_msg_template["id"]: stream_msg_template, - pm_template["id"]: pm_template, + dm_template["id"]: dm_template, group_dm_template["id"]: group_dm_template, }, ), @@ -1140,7 +1140,7 @@ def index_multiple_topic_msg( @pytest.fixture def index_user(empty_index: Index) -> Index: """ - Expected index of initial_data when model.narrow = [['pm_with', + Expected index of initial_data when model.narrow = [['dm_with', 'boo@zulip.com'], """ user_ids = frozenset({5179, 5140}) @@ -1153,7 +1153,7 @@ def index_user(empty_index: Index) -> Index: @pytest.fixture def index_user_multiple(empty_index: Index) -> Index: """ - Expected index of initial_data when model.narrow = [['pm_with', + Expected index of initial_data when model.narrow = [['dm_with', 'boo@zulip.com, bar@zulip.com'], """ user_ids = frozenset({5179, 5140, 5180}) diff --git a/tests/core/test_core.py b/tests/core/test_core.py index 905bb8af58..205be04e04 100644 --- a/tests/core/test_core.py +++ b/tests/core/test_core.py @@ -514,7 +514,7 @@ def test_stream_muting_confirmation_popup( "Default_all_msg_search", "redo_default_search", "search_within_stream", - "pm_search_again", + "dm_search_again", "search_within_topic_narrow", ], ) diff --git a/tests/model/test_model.py b/tests/model/test_model.py index 9e98379548..68665b1196 100644 --- a/tests/model/test_model.py +++ b/tests/model/test_model.py @@ -406,9 +406,9 @@ def test_is_search_narrow(self, model, narrow, is_search_narrow): "bad_args", [ dict(topic="some topic"), - dict(stream="foo", pm_with="someone"), - dict(topic="blah", pm_with="someone"), - dict(pm_with="someone", topic="foo"), + dict(stream="foo", dm_with="someone"), + dict(topic="blah", dm_with="someone"), + dict(dm_with="someone", topic="foo"), ], ) def test_set_narrow_bad_input(self, model, bad_args): @@ -427,7 +427,7 @@ def test_set_narrow_bad_input(self, model, bad_args): ([["is", "starred"]], dict(starred=True)), ([["is", "mentioned"]], dict(mentioned=True)), ([["is", "private"]], dict(pms=True)), - ([["pm-with", "FOO@zulip.com"]], dict(pm_with="FOO@zulip.com")), + ([["pm-with", "FOO@zulip.com"]], dict(dm_with="FOO@zulip.com")), ], ) def test_set_narrow_already_set(self, model, narrow, good_args): @@ -448,7 +448,7 @@ def test_set_narrow_already_set(self, model, narrow, good_args): ([], [["is", "starred"]], dict(starred=True)), ([], [["is", "mentioned"]], dict(mentioned=True)), ([], [["is", "private"]], dict(pms=True)), - ([], [["pm-with", "FOOBOO@gmail.com"]], dict(pm_with="FOOBOO@gmail.com")), + ([], [["pm-with", "FOOBOO@gmail.com"]], dict(dm_with="FOOBOO@gmail.com")), ], ) def test_set_narrow_not_already_set( diff --git a/tests/ui/test_ui_tools.py b/tests/ui/test_ui_tools.py index 1f2f0e1ccf..cf170a5a04 100644 --- a/tests/ui/test_ui_tools.py +++ b/tests/ui/test_ui_tools.py @@ -1152,7 +1152,7 @@ def mock_external_classes(self, mocker): def test_menu_view(self, mocker): self.streams_view = mocker.patch(VIEWS + ".LeftColumnView.streams_view") home_button = mocker.patch(VIEWS + ".HomeButton") - pm_button = mocker.patch(VIEWS + ".PMButton") + dm_button = mocker.patch(VIEWS + ".PMButton") starred_button = mocker.patch(VIEWS + ".StarredButton") mocker.patch(VIEWS + ".urwid.ListBox") mocker.patch(VIEWS + ".urwid.SimpleFocusListWalker") @@ -1161,7 +1161,7 @@ def test_menu_view(self, mocker): home_button.assert_called_once_with( controller=left_col_view.controller, count=2 ) - pm_button.assert_called_once_with(controller=left_col_view.controller, count=0) + dm_button.assert_called_once_with(controller=left_col_view.controller, count=0) starred_button.assert_called_once_with( controller=left_col_view.controller, count=3 ) diff --git a/tests/ui_tools/test_boxes.py b/tests/ui_tools/test_boxes.py index aff7209193..91dc3c401f 100644 --- a/tests/ui_tools/test_boxes.py +++ b/tests/ui_tools/test_boxes.py @@ -186,7 +186,7 @@ def test_generic_autocomplete_stream_and_topic( ([1001], False, []), ([1001, 11], True, [11]), ], - ids=["pm_only_with_oneself", "group_pm"], + ids=["dm_only_with_oneself", "group_dm"], ) def test_not_calling_typing_method_to_oneself( self, diff --git a/tests/ui_tools/test_buttons.py b/tests/ui_tools/test_buttons.py index adc2faa127..ca23b2a5e2 100644 --- a/tests/ui_tools/test_buttons.py +++ b/tests/ui_tools/test_buttons.py @@ -181,12 +181,12 @@ def test_update_widget( class TestPMButton: def test_button_text_length(self, mocker: MockerFixture, count: int = 10) -> None: - pm_button = PMButton(controller=mocker.Mock(), count=count) - assert len(pm_button.label_text) == 20 + dm_button = PMButton(controller=mocker.Mock(), count=count) + assert len(dm_button.label_text) == 20 def test_button_text_title(self, mocker: MockerFixture, count: int = 10) -> None: - pm_button = PMButton(controller=mocker.Mock(), count=count) - title_text = pm_button.label_text[:-3].strip() + dm_button = PMButton(controller=mocker.Mock(), count=count) + title_text = dm_button.label_text[:-3].strip() assert title_text == "Direct messages" diff --git a/tests/ui_tools/test_messages.py b/tests/ui_tools/test_messages.py index b901c33618..f96229ec7c 100644 --- a/tests/ui_tools/test_messages.py +++ b/tests/ui_tools/test_messages.py @@ -883,7 +883,7 @@ def test_main_view_generates_stream_header( {"type": "stream"}, ], ids=[ - "larger_pm_group", + "larger_dm_group", "stream_before", ], ) diff --git a/tests/ui_tools/test_popups.py b/tests/ui_tools/test_popups.py index 878be178c4..840735029c 100644 --- a/tests/ui_tools/test_popups.py +++ b/tests/ui_tools/test_popups.py @@ -1023,8 +1023,8 @@ def test_keypress_any_key( ], ids=[ "stream_message_id", - "pm_message_id", - "group_pm_message_id", + "dm_message_id", + "group_dm_message_id", ], ) def test_keypress_edit_history( diff --git a/zulipterminal/core.py b/zulipterminal/core.py index a2b86b93a7..e18ebf936d 100644 --- a/zulipterminal/core.py +++ b/zulipterminal/core.py @@ -645,7 +645,7 @@ def narrow_to_user( ) -> None: self._narrow_to( anchor=contextual_message_id, - pm_with=", ".join(recipient_emails), + dm_with=", ".join(recipient_emails), ) def narrow_to_all_messages( diff --git a/zulipterminal/helper.py b/zulipterminal/helper.py index 97b2f571b8..329df8b83f 100644 --- a/zulipterminal/helper.py +++ b/zulipterminal/helper.py @@ -238,7 +238,7 @@ def _set_count_in_view( toggled_stream_id = controller.view.topic_w.stream_button.stream_id user_buttons_list = controller.view.user_w.users_btn_list all_msg = controller.view.home_button - all_dm = controller.view.pm_button + all_dm = controller.view.dm_button all_mentioned = controller.view.mentioned_button for message in changed_messages: user_id = message["sender_id"] @@ -719,12 +719,12 @@ def notify_if_message_sent_outside_narrow( topic_narrow = stream_narrow + [["topic", message["subject"]]] check_narrow_and_notify(stream_narrow, topic_narrow, controller) elif message["type"] == "private": - pm_narrow = [["is", "private"]] + dm_narrow = [["is", "private"]] recipient_emails = [ controller.model.user_id_email_dict[user_id] for user_id in message["to"] ] - pm_with_narrow = [["pm-with", ", ".join(recipient_emails)]] - check_narrow_and_notify(pm_narrow, pm_with_narrow, controller) + dm_with_narrow = [["pm-with", ", ".join(recipient_emails)]] + check_narrow_and_notify(dm_narrow, dm_with_narrow, controller) def hash_util_decode(string: str) -> str: diff --git a/zulipterminal/model.py b/zulipterminal/model.py index 98eb03efa1..58c67d29cc 100644 --- a/zulipterminal/model.py +++ b/zulipterminal/model.py @@ -300,7 +300,7 @@ def set_narrow( stream: Optional[str] = None, topic: Optional[str] = None, pms: bool = False, - pm_with: Optional[str] = None, + dm_with: Optional[str] = None, starred: bool = False, mentioned: bool = False, ) -> bool: @@ -310,7 +310,7 @@ def set_narrow( frozenset(["stream"]): [["stream", stream]], frozenset(["stream", "topic"]): [["stream", stream], ["topic", topic]], frozenset(["pms"]): [["is", "private"]], - frozenset(["pm_with"]): [["pm-with", pm_with]], + frozenset(["dm_with"]): [["pm-with", dm_with]], frozenset(["starred"]): [["is", "starred"]], frozenset(["mentioned"]): [["is", "mentioned"]], } @@ -324,8 +324,8 @@ def set_narrow( if new_narrow != self.narrow: self.narrow = new_narrow - if pm_with is not None and new_narrow[0][0] == "pm-with": - users = pm_with.split(", ") + if dm_with is not None and new_narrow[0][0] == "pm-with": + users = dm_with.split(", ") self.recipients = frozenset( [self.user_dict[user]["user_id"] for user in users] + [self.user_id] ) diff --git a/zulipterminal/server_url.py b/zulipterminal/server_url.py index ca996a2202..4c1f0fccef 100644 --- a/zulipterminal/server_url.py +++ b/zulipterminal/server_url.py @@ -61,12 +61,12 @@ def near_dm_message_url(server_url: str, message: Message) -> str: message_id = str(message["id"]) str_user_ids = [str(recipient["id"]) for recipient in message["display_recipient"]] - pm_str = ",".join(str_user_ids) + "-pm" + dm_str = ",".join(str_user_ids) + "-pm" parts = [ server_url, "#narrow", "pm-with", - pm_str, + dm_str, "near", message_id, ] diff --git a/zulipterminal/ui.py b/zulipterminal/ui.py index 41ccc75485..9f8bac8871 100644 --- a/zulipterminal/ui.py +++ b/zulipterminal/ui.py @@ -270,7 +270,7 @@ def keypress(self, size: urwid_Box, key: str) -> Optional[str]: self.middle_column.keypress(size, key) return key elif is_command_key("ALL_PM", key): - self.pm_button.activate(key) + self.dm_button.activate(key) elif is_command_key("ALL_STARRED", key): self.starred_button.activate(key) elif is_command_key("ALL_MENTIONS", key): diff --git a/zulipterminal/ui_tools/views.py b/zulipterminal/ui_tools/views.py index 6f85b2b501..1d4124268c 100644 --- a/zulipterminal/ui_tools/views.py +++ b/zulipterminal/ui_tools/views.py @@ -793,7 +793,7 @@ def menu_view(self) -> Any: self.view.home_button = HomeButton(controller=self.controller, count=count) count = self.model.unread_counts.get("all_dms", 0) - self.view.pm_button = PMButton(controller=self.controller, count=count) + self.view.dm_button = PMButton(controller=self.controller, count=count) self.view.mentioned_button = MentionedButton( controller=self.controller, @@ -807,7 +807,7 @@ def menu_view(self) -> Any: ) menu_btn_list = [ self.view.home_button, - self.view.pm_button, + self.view.dm_button, self.view.mentioned_button, self.view.starred_button, ]