Skip to content

Commit

Permalink
refactor: Replace 'pm_' with 'dm_'.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajnus committed Nov 13, 2024
1 parent cd8b0f7 commit 95c5b7e
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 35 deletions.
28 changes: 14 additions & 14 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -519,12 +519,12 @@ def private_message_fixture(request: Any) -> Message:


@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.
Expand All @@ -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]:
"""
Expand All @@ -546,7 +546,7 @@ def messages_successful_response(
"anchor": 10000000000000000,
"messages": [
stream_msg_template,
pm_template,
dm_template,
group_dm_template,
],
"result": "success",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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(
Expand All @@ -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,
},
),
Expand Down Expand Up @@ -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',
'[email protected]'],
"""
user_ids = frozenset({5179, 5140})
Expand All @@ -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',
'[email protected], [email protected]'],
"""
user_ids = frozenset({5179, 5140, 5180})
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/test_ui_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion tests/ui_tools/test_boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions tests/ui_tools/test_buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down
2 changes: 1 addition & 1 deletion tests/ui_tools/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ def test_main_view_generates_stream_header(
{"type": "stream"},
],
ids=[
"larger_pm_group",
"larger_dm_group",
"stream_before",
],
)
Expand Down
4 changes: 2 additions & 2 deletions tests/ui_tools/test_popups.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion zulipterminal/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions zulipterminal/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions zulipterminal/server_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]
Expand Down
2 changes: 1 addition & 1 deletion zulipterminal/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions zulipterminal/ui_tools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
]
Expand Down

0 comments on commit 95c5b7e

Please sign in to comment.