forked from zulip/zulip-terminal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Ajnus/issue_#1344
Issue zulip#1344 (terminal cant find @issuezulip#1344 for cloning and local testing)
- Loading branch information
Showing
31 changed files
with
165 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -425,7 +425,7 @@ def display_recipient_factory( | |
recipient_details_list: List[Tuple[int, str]] | ||
) -> List[Dict[str, Any]]: | ||
""" | ||
Generate display_recipient field for (PM/group) messages | ||
Generate display_recipient field for (DM/group) messages | ||
""" | ||
return [ | ||
{ | ||
|
@@ -448,9 +448,9 @@ def msg_template_factory( | |
recipients: Union[str, List[Dict[str, Any]]] = "PTEST", | ||
) -> Message: | ||
""" | ||
Generate message template for all types of messages(stream/PM/group) | ||
Generate message template for all types of messages(stream/DM/group) | ||
""" | ||
# TODO: Separate Message into distinct types for stream and private messages. | ||
# TODO: Separate Message into distinct types for stream and direct messages. | ||
message = Message( | ||
id=msg_id, | ||
sender_full_name="Foo Foo", | ||
|
@@ -500,31 +500,31 @@ 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) | ||
|
||
|
||
@pytest.fixture | ||
def group_pm_template() -> Message: | ||
def group_dm_template() -> Message: | ||
recipients = display_recipient_factory( | ||
[(5179, "Boo Boo"), (5140, "Foo Foo"), (5180, "Bar Bar")] | ||
) | ||
return msg_template_factory(537288, "private", 1520918737, recipients=recipients) | ||
|
||
|
||
@pytest.fixture(params=["pm_template", "group_pm_template"]) | ||
def private_message_fixture(request: Any) -> Message: | ||
@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_pm_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, pms 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,8 +535,8 @@ def message_fixture(request: Any) -> Message: | |
@pytest.fixture | ||
def messages_successful_response( | ||
stream_msg_template: Message, | ||
pm_template: Message, | ||
group_pm_template: Message, | ||
dm_template: Message, | ||
group_dm_template: Message, | ||
) -> Dict[str, Any]: | ||
""" | ||
A successful response from a /messages API query. | ||
|
@@ -546,8 +546,8 @@ def messages_successful_response( | |
"anchor": 10000000000000000, | ||
"messages": [ | ||
stream_msg_template, | ||
pm_template, | ||
group_pm_template, | ||
dm_template, | ||
group_dm_template, | ||
], | ||
"result": "success", | ||
"msg": "", | ||
|
@@ -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,16 +1060,16 @@ def initial_index() -> Index: | |
|
||
@pytest.fixture | ||
def empty_index( | ||
stream_msg_template: Message, pm_template: Message, group_pm_template: Message | ||
stream_msg_template: Message, dm_template: Message, group_dm_template: Message | ||
) -> Index: | ||
return deepcopy( | ||
Index( | ||
pointer=dict(), | ||
all_msg_ids=set(), | ||
starred_msg_ids=set(), | ||
mentioned_msg_ids=set(), | ||
private_msg_ids=set(), | ||
private_msg_ids_by_user_ids=defaultdict(set, {}), | ||
direct_msg_ids=set(), | ||
direct_msg_ids_by_user_ids=defaultdict(set, {}), | ||
stream_msg_ids_by_stream_id=defaultdict(set, {}), | ||
topic_msg_ids=defaultdict(dict, {}), | ||
edited_messages=set(), | ||
|
@@ -1079,8 +1079,8 @@ def empty_index( | |
lambda: {}, | ||
{ | ||
stream_msg_template["id"]: stream_msg_template, | ||
pm_template["id"]: pm_template, | ||
group_pm_template["id"]: group_pm_template, | ||
dm_template["id"]: dm_template, | ||
group_dm_template["id"]: group_dm_template, | ||
}, | ||
), | ||
) | ||
|
@@ -1104,7 +1104,7 @@ def index_stream(empty_index: Index) -> Index: | |
""" | ||
index = empty_index | ||
index["stream_msg_ids_by_stream_id"] = defaultdict(set, {205: {537286}}) | ||
index["private_msg_ids"] = {537287, 537288} | ||
index["direct_msg_ids"] = {537287, 537288} | ||
return index | ||
|
||
|
||
|
@@ -1140,26 +1140,26 @@ 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}) | ||
index = empty_index | ||
index["private_msg_ids_by_user_ids"] = defaultdict(set, {user_ids: {537287}}) | ||
index["private_msg_ids"] = {537287, 537288} | ||
index["direct_msg_ids_by_user_ids"] = defaultdict(set, {user_ids: {537287}}) | ||
index["direct_msg_ids"] = {537287, 537288} | ||
return 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}) | ||
index = empty_index | ||
index["private_msg_ids_by_user_ids"] = defaultdict(set, {user_ids: {537288}}) | ||
index["private_msg_ids"] = {537287, 537288} | ||
index["direct_msg_ids_by_user_ids"] = defaultdict(set, {user_ids: {537288}}) | ||
index["direct_msg_ids"] = {537287, 537288} | ||
return index | ||
|
||
|
||
|
@@ -1178,7 +1178,7 @@ def index_all_starred(empty_index: Index, request: Any) -> Index: | |
msgs_with_stars = request.param | ||
index = empty_index | ||
index["starred_msg_ids"] = msgs_with_stars | ||
index["private_msg_ids"] = {537287, 537288} | ||
index["direct_msg_ids"] = {537287, 537288} | ||
for msg_id, msg in index["messages"].items(): | ||
if msg_id in msgs_with_stars and "starred" not in msg["flags"]: | ||
msg["flags"].append("starred") | ||
|
@@ -1192,7 +1192,7 @@ def index_all_mentions( | |
mentioned_messages, wildcard_mentioned_messages = mentioned_messages_combination | ||
index = empty_index | ||
index["mentioned_msg_ids"] = mentioned_messages | wildcard_mentioned_messages | ||
index["private_msg_ids"] = {537287, 537288} | ||
index["direct_msg_ids"] = {537287, 537288} | ||
for msg_id, msg in index["messages"].items(): | ||
if msg_id in mentioned_messages and "mentioned" not in msg["flags"]: | ||
msg["flags"].append("mentioned") | ||
|
@@ -1468,12 +1468,12 @@ def classified_unread_counts() -> Dict[str, Any]: | |
""" | ||
return { | ||
"all_msg": 12, | ||
"all_pms": 8, | ||
"all_dms": 8, | ||
"unread_topics": { | ||
(1000, "Some general unread topic"): 3, | ||
(99, "Some private unread topic"): 1, | ||
}, | ||
"unread_pms": { | ||
"unread_dms": { | ||
1: 2, | ||
2: 1, | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -477,16 +477,16 @@ def test_set_narrow_not_already_set( | |
{"topic_msg_ids": {1: {"BOO": {0, 1}}}}, | ||
set(), | ||
), | ||
([["is", "private"]], {"private_msg_ids": {0, 1}}, {0, 1}), | ||
([["is", "private"]], {"direct_msg_ids": {0, 1}}, {0, 1}), | ||
( | ||
[["pm-with", "[email protected]"]], | ||
{"private_msg_ids_by_user_ids": {frozenset({1, 2}): {0, 1}}}, | ||
{"direct_msg_ids_by_user_ids": {frozenset({1, 2}): {0, 1}}}, | ||
{0, 1}, | ||
), | ||
( | ||
[["pm-with", "[email protected]"]], | ||
{ # Covers recipient empty-set case | ||
"private_msg_ids_by_user_ids": { | ||
"direct_msg_ids_by_user_ids": { | ||
frozenset({1, 3}): {0, 1} # NOTE {1,3} not {1,2} | ||
} | ||
}, | ||
|
@@ -3988,8 +3988,8 @@ def test__handle_user_settings_event(self, mocker, model, value): | |
assert model.user_settings()[setting] == value | ||
|
||
@pytest.mark.parametrize("setting", [True, False]) | ||
def test_update_pm_content_in_desktop_notifications(self, mocker, model, setting): | ||
setting_name = "pm_content_in_desktop_notifications" | ||
def test_update_dm_content_in_desktop_notifications(self, mocker, model, setting): | ||
setting_name = "dm_content_in_desktop_notifications" | ||
event = { | ||
"type": "update_global_notifications", | ||
"notification_name": setting_name, | ||
|
@@ -4291,20 +4291,20 @@ def test_next_unread_topic_from_message__empty_narrow( | |
|
||
assert unread_topic == next_unread_topic | ||
|
||
def test_get_next_unread_pm(self, model): | ||
def test_get_next_unread_dm(self, model): | ||
model.unread_counts = {"unread_pms": {1: 1, 2: 1}} | ||
return_value = model.get_next_unread_pm() | ||
assert return_value == 1 | ||
assert model.last_unread_pm == 1 | ||
|
||
def test_get_next_unread_pm_again(self, model): | ||
def test_get_next_unread_dm_again(self, model): | ||
model.unread_counts = {"unread_pms": {1: 1, 2: 1}} | ||
model.last_unread_pm = 1 | ||
return_value = model.get_next_unread_pm() | ||
assert return_value == 2 | ||
assert model.last_unread_pm == 2 | ||
|
||
def test_get_next_unread_pm_no_unread(self, model): | ||
def test_get_next_unread_dm_no_unread(self, model): | ||
model.unread_counts = {"unread_pms": {}} | ||
return_value = model.get_next_unread_pm() | ||
assert return_value is None | ||
|
Oops, something went wrong.