Skip to content

Commit 84e1bfe

Browse files
committed
refactor: Replace '_pm' with '_dm' - rebased.
1 parent a5703a7 commit 84e1bfe

File tree

10 files changed

+32
-32
lines changed

10 files changed

+32
-32
lines changed

tests/conftest.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -506,20 +506,20 @@ def pm_template() -> Message:
506506

507507

508508
@pytest.fixture
509-
def group_pm_template() -> Message:
509+
def group_dm_template() -> Message:
510510
recipients = display_recipient_factory(
511511
[(5179, "Boo Boo"), (5140, "Foo Foo"), (5180, "Bar Bar")]
512512
)
513513
return msg_template_factory(537288, "private", 1520918737, recipients=recipients)
514514

515515

516-
@pytest.fixture(params=["pm_template", "group_pm_template"])
516+
@pytest.fixture(params=["pm_template", "group_dm_template"])
517517
def direct_message_fixture(request: Any) -> Message:
518518
return request.getfixturevalue(request.param)
519519

520520

521521
@pytest.fixture(
522-
params=["stream_msg_template", "pm_template", "group_pm_template"],
522+
params=["stream_msg_template", "pm_template", "group_dm_template"],
523523
ids=["stream_message", "pm_message", "group_pm_message"],
524524
)
525525
def message_fixture(request: Any) -> Message:
@@ -536,7 +536,7 @@ def message_fixture(request: Any) -> Message:
536536
def messages_successful_response(
537537
stream_msg_template: Message,
538538
pm_template: Message,
539-
group_pm_template: Message,
539+
group_dm_template: Message,
540540
) -> Dict[str, Any]:
541541
"""
542542
A successful response from a /messages API query.
@@ -547,7 +547,7 @@ def messages_successful_response(
547547
"messages": [
548548
stream_msg_template,
549549
pm_template,
550-
group_pm_template,
550+
group_dm_template,
551551
],
552552
"result": "success",
553553
"msg": "",
@@ -1060,7 +1060,7 @@ def initial_index() -> Index:
10601060

10611061
@pytest.fixture
10621062
def empty_index(
1063-
stream_msg_template: Message, pm_template: Message, group_pm_template: Message
1063+
stream_msg_template: Message, pm_template: Message, group_dm_template: Message
10641064
) -> Index:
10651065
return deepcopy(
10661066
Index(
@@ -1080,7 +1080,7 @@ def empty_index(
10801080
{
10811081
stream_msg_template["id"]: stream_msg_template,
10821082
pm_template["id"]: pm_template,
1083-
group_pm_template["id"]: group_pm_template,
1083+
group_dm_template["id"]: group_dm_template,
10841084
},
10851085
),
10861086
)
@@ -1468,7 +1468,7 @@ def classified_unread_counts() -> Dict[str, Any]:
14681468
"""
14691469
return {
14701470
"all_msg": 12,
1471-
"all_pms": 8,
1471+
"all_dms": 8,
14721472
"unread_topics": {
14731473
(1000, "Some general unread topic"): 3,
14741474
(99, "Some private unread topic"): 1,

tests/core/test_core.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def test_narrow_to_all_messages(
287287
assert msg_ids == id_list
288288
assert final_focus_msg_id == expected_final_focus_msg_id
289289

290-
def test_narrow_to_all_pm(
290+
def test_narrow_to_all_dm(
291291
self, mocker: MockerFixture, controller: Controller, index_user: Index
292292
) -> None:
293293
controller.model.narrow = []
@@ -296,7 +296,7 @@ def test_narrow_to_all_pm(
296296
controller.model.user_id = 1
297297
controller.model.user_email = "some@email"
298298

299-
controller.narrow_to_all_pm() # FIXME: Add id narrowing test
299+
controller.narrow_to_all_dm() # FIXME: Add id narrowing test
300300

301301
assert controller.model.narrow == [["is", "private"]]
302302
controller.view.message_view.log.clear.assert_called_once_with()

tests/model/test_model.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4291,20 +4291,20 @@ def test_next_unread_topic_from_message__empty_narrow(
42914291

42924292
assert unread_topic == next_unread_topic
42934293

4294-
def test_get_next_unread_pm(self, model):
4294+
def test_get_next_unread_dm(self, model):
42954295
model.unread_counts = {"unread_pms": {1: 1, 2: 1}}
42964296
return_value = model.get_next_unread_pm()
42974297
assert return_value == 1
42984298
assert model.last_unread_pm == 1
42994299

4300-
def test_get_next_unread_pm_again(self, model):
4300+
def test_get_next_unread_dm_again(self, model):
43014301
model.unread_counts = {"unread_pms": {1: 1, 2: 1}}
43024302
model.last_unread_pm = 1
43034303
return_value = model.get_next_unread_pm()
43044304
assert return_value == 2
43054305
assert model.last_unread_pm == 2
43064306

4307-
def test_get_next_unread_pm_no_unread(self, model):
4307+
def test_get_next_unread_dm_no_unread(self, model):
43084308
model.unread_counts = {"unread_pms": {}}
43094309
return_value = model.get_next_unread_pm()
43104310
assert return_value is None

tests/ui/test_ui_tools.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ def test_keypress_NEXT_UNREAD_PM_stream(
960960
)
961961

962962
@pytest.mark.parametrize("key", keys_for_command("NEXT_UNREAD_PM"))
963-
def test_keypress_NEXT_UNREAD_PM_no_pm(
963+
def test_keypress_NEXT_UNREAD_PM_no_dm(
964964
self, mid_col_view, mocker, key, widget_size
965965
):
966966
size = widget_size(mid_col_view)
@@ -1128,7 +1128,7 @@ def mock_external_classes(self, mocker):
11281128
self.view.model = mocker.Mock()
11291129
self.view.model.unread_counts = { # Minimal, though an UnreadCounts
11301130
"all_msg": 2,
1131-
"all_pms": 0,
1131+
"all_dms": 0,
11321132
"streams": {
11331133
86: 1,
11341134
14: 1,

zulipterminal/core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ def narrow_to_all_messages(
653653
) -> None:
654654
self._narrow_to(anchor=contextual_message_id)
655655

656-
def narrow_to_all_pm(self, *, contextual_message_id: Optional[int] = None) -> None:
656+
def narrow_to_all_dm(self, *, contextual_message_id: Optional[int] = None) -> None:
657657
self._narrow_to(anchor=contextual_message_id, pms=True)
658658

659659
def narrow_to_all_starred(self) -> None:

zulipterminal/helper.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class Index(TypedDict):
135135

136136
class UnreadCounts(TypedDict):
137137
all_msg: int
138-
all_pms: int
138+
all_dms: int
139139
all_mentions: int
140140
unread_topics: Dict[Tuple[int, str], int] # stream_id, topic
141141
unread_pms: Dict[int, int] # sender_id
@@ -227,7 +227,7 @@ def _set_count_in_view(
227227
) -> None:
228228
"""
229229
This function for the most part contains the logic for setting the
230-
count in the UI buttons. The later buttons (all_msg, all_pms)
230+
count in the UI buttons. The later buttons (all_msg, all_dms)
231231
additionally set the current count in the model and make use of the
232232
same in the UI.
233233
"""
@@ -238,7 +238,7 @@ def _set_count_in_view(
238238
toggled_stream_id = controller.view.topic_w.stream_button.stream_id
239239
user_buttons_list = controller.view.user_w.users_btn_list
240240
all_msg = controller.view.home_button
241-
all_pm = controller.view.pm_button
241+
all_dm = controller.view.pm_button
242242
all_mentioned = controller.view.mentioned_button
243243
for message in changed_messages:
244244
user_id = message["sender_id"]
@@ -277,8 +277,8 @@ def _set_count_in_view(
277277
if user_button.user_id == user_id:
278278
user_button.update_count(user_button.count + new_count)
279279
break
280-
unread_counts["all_pms"] += new_count
281-
all_pm.update_count(unread_counts["all_pms"])
280+
unread_counts["all_dms"] += new_count
281+
all_dm.update_count(unread_counts["all_dms"])
282282

283283
if add_to_counts:
284284
unread_counts["all_msg"] += new_count
@@ -487,7 +487,7 @@ def classify_unread_counts(model: Any) -> UnreadCounts:
487487

488488
unread_counts = UnreadCounts(
489489
all_msg=0,
490-
all_pms=0,
490+
all_dms=0,
491491
all_mentions=0,
492492
unread_topics=dict(),
493493
unread_pms=dict(),
@@ -502,7 +502,7 @@ def classify_unread_counts(model: Any) -> UnreadCounts:
502502
count = len(dm["unread_message_ids"])
503503
unread_counts["unread_pms"][dm["sender_id"]] = count
504504
unread_counts["all_msg"] += count
505-
unread_counts["all_pms"] += count
505+
unread_counts["all_dms"] += count
506506

507507
for stream in unread_msg_counts["streams"]:
508508
count = len(stream["unread_message_ids"])
@@ -522,13 +522,13 @@ def classify_unread_counts(model: Any) -> UnreadCounts:
522522
unread_counts["all_msg"] += count
523523

524524
# store unread count of group dms in `unread_huddles`
525-
for group_pm in unread_msg_counts["huddles"]:
526-
count = len(group_pm["unread_message_ids"])
527-
user_ids = group_pm["user_ids_string"].split(",")
525+
for group in unread_msg_counts["huddles"]:
526+
count = len(group["unread_message_ids"])
527+
user_ids = group["user_ids_string"].split(",")
528528
user_ids = frozenset(map(int, user_ids))
529529
unread_counts["unread_huddles"][user_ids] = count
530530
unread_counts["all_msg"] += count
531-
unread_counts["all_pms"] += count
531+
unread_counts["all_dms"] += count
532532

533533
return unread_counts
534534

zulipterminal/server_url.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def near_stream_message_url(server_url: str, message: Message) -> str:
5353
return full_url
5454

5555

56-
def near_pm_message_url(server_url: str, message: Message) -> str:
56+
def near_dm_message_url(server_url: str, message: Message) -> str:
5757
"""
5858
Returns the complete encoded URL of a message from #narrow/pm-with.
5959
Referred from zerver/lib/url_encoding.py.
@@ -83,5 +83,5 @@ def near_message_url(server_url: str, message: Message) -> str:
8383
if message["type"] == "stream":
8484
url = near_stream_message_url(server_url, message)
8585
else:
86-
url = near_pm_message_url(server_url, message)
86+
url = near_dm_message_url(server_url, message)
8787
return url

zulipterminal/ui_tools/buttons.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def __init__(self, *, controller: Any, count: int) -> None:
152152
label_markup=(None, button_text),
153153
prefix_markup=("title", DIRECT_MESSAGE_MARKER),
154154
suffix_markup=("unread_count", ""),
155-
show_function=controller.narrow_to_all_pm,
155+
show_function=controller.narrow_to_all_dm,
156156
count=count,
157157
)
158158

zulipterminal/ui_tools/messages.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
938938
self.model.unset_search_narrow()
939939
if self.message["type"] == "private":
940940
if len(self.model.narrow) == 1 and self.model.narrow[0][0] == "pm-with":
941-
self.model.controller.narrow_to_all_pm(
941+
self.model.controller.narrow_to_all_dm(
942942
contextual_message_id=self.message["id"],
943943
)
944944
else:

zulipterminal/ui_tools/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ def menu_view(self) -> Any:
792792
count = self.model.unread_counts.get("all_msg", 0)
793793
self.view.home_button = HomeButton(controller=self.controller, count=count)
794794

795-
count = self.model.unread_counts.get("all_pms", 0)
795+
count = self.model.unread_counts.get("all_dms", 0)
796796
self.view.pm_button = PMButton(controller=self.controller, count=count)
797797

798798
self.view.mentioned_button = MentionedButton(

0 commit comments

Comments
 (0)