-
-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: boxes/buttons/ui: Remove
emails
from private_box_view.
Prior to this commit, everytime the private_box_view had to be initiated with recipients, the emails of the recipients was also requested along with their user_ids. This commit removes that parameter and hence makes the private_box_view reliant on only the list of `user_id`s received. Tests updated.
- Loading branch information
Showing
5 changed files
with
21 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -441,7 +441,6 @@ def test_keypress_OPEN_DRAFT( | |
) | ||
else: | ||
mocked_private_box_view.assert_called_once_with( | ||
emails=["[email protected]", "[email protected]"], | ||
recipient_user_ids=draft["to"], | ||
) | ||
|
||
|
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 |
---|---|---|
|
@@ -58,7 +58,7 @@ def test_init(self, write_box): | |
|
||
def test_not_calling_typing_method_without_recipients(self, mocker, write_box): | ||
write_box.model.send_typing_status_by_user_ids = mocker.Mock() | ||
write_box.private_box_view(emails=[], recipient_user_ids=[]) | ||
write_box.private_box_view(recipient_user_ids=[]) | ||
# Set idle_status_tracking to True to avoid setting off the | ||
# idleness tracker function. | ||
write_box.idle_status_tracking = True | ||
|
@@ -69,10 +69,10 @@ def test_not_calling_typing_method_without_recipients(self, mocker, write_box): | |
assert not write_box.model.send_typing_status_by_user_ids.called | ||
|
||
@pytest.mark.parametrize( | ||
"emails, user_ids, expect_method_called, typing_recipient_user_ids", | ||
"user_ids, expect_method_called, typing_recipient_user_ids", | ||
[ | ||
(["[email protected]"], [1001], False, []), | ||
(["[email protected]", "[email protected]"], [1001, 11], True, [11]), | ||
([1001], False, []), | ||
([1001, 11], True, [11]), | ||
], | ||
ids=["pm_only_with_oneself", "group_pm"], | ||
) | ||
|
@@ -81,14 +81,15 @@ def test_not_calling_typing_method_to_oneself( | |
mocker, | ||
write_box, | ||
expect_method_called, | ||
emails, | ||
logged_on_user, | ||
user_ids, | ||
typing_recipient_user_ids, | ||
user_id_email_dict, | ||
): | ||
write_box.model.send_typing_status_by_user_ids = mocker.Mock() | ||
write_box.model.user_id_email_dict = user_id_email_dict | ||
write_box.model.user_id = logged_on_user["user_id"] | ||
write_box.private_box_view(emails=emails, recipient_user_ids=user_ids) | ||
write_box.private_box_view(recipient_user_ids=user_ids) | ||
# Set idle_status_tracking to True to avoid setting off the | ||
# idleness tracker function. | ||
write_box.idle_status_tracking = True | ||
|
@@ -115,7 +116,7 @@ def test_not_calling_send_private_message_without_recipients( | |
self, key, mocker, write_box, widget_size | ||
): | ||
write_box.model.send_private_message = mocker.Mock() | ||
write_box.private_box_view(emails=[], recipient_user_ids=[]) | ||
write_box.private_box_view(recipient_user_ids=[]) | ||
write_box.msg_write_box.edit_text = "random text" | ||
|
||
size = widget_size(write_box) | ||
|
@@ -725,11 +726,10 @@ def test__to_box_autocomplete( | |
], | ||
) | ||
def test__to_box_autocomplete_with_spaces( | ||
self, write_box, text, expected_text, widget_size | ||
self, write_box, text, expected_text, widget_size, user_id_email_dict | ||
): | ||
write_box.private_box_view( | ||
emails=["[email protected]"], recipient_user_ids=[1] | ||
) | ||
write_box.model.user_id_email_dict = user_id_email_dict | ||
write_box.private_box_view(recipient_user_ids=[1]) | ||
write_box.to_write_box.set_edit_text(text) | ||
write_box.to_write_box.set_edit_pos(len(text)) | ||
write_box.focus_position = write_box.FOCUS_CONTAINER_HEADER | ||
|
@@ -1310,18 +1310,17 @@ def test_keypress_MARKDOWN_HELP(self, mocker, write_box, key, widget_size): | |
], | ||
) | ||
def test_write_box_header_contents( | ||
self, write_box, expected_box_size, mocker, msg_type | ||
self, write_box, expected_box_size, mocker, msg_type, user_id_email_dict | ||
): | ||
mocker.patch(WRITEBOX + "._set_stream_write_box_style") | ||
mocker.patch(WRITEBOX + ".set_editor_mode") | ||
write_box.model.user_id_email_dict = user_id_email_dict | ||
if msg_type == "stream": | ||
write_box.stream_box_view(1000) | ||
elif msg_type == "stream_edit": | ||
write_box.stream_box_edit_view(1000) | ||
else: | ||
write_box.private_box_view( | ||
emails=["[email protected]"], recipient_user_ids=[1] | ||
) | ||
write_box.private_box_view(recipient_user_ids=[1]) | ||
|
||
assert len(write_box.header_write_box.widget_list) == expected_box_size | ||
|
||
|
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