-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test_core: Add tests for show_typing_notification
Add diffrernt cases of footer notification.Earlier just one test was presnt as not much scenarios were possible.The test now has it's own user_dict which is used to extract name for footer notifcation out of emails present in active_conversation_info.
- Loading branch information
Subhasish-Behera
committed
Apr 14, 2023
1 parent
c40149d
commit 1c6a648
Showing
1 changed file
with
110 additions
and
30 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 |
---|---|---|
|
@@ -553,6 +553,18 @@ def test_maximum_popup_dimensions( | |
[ | ||
case({"[email protected]"}, id="in_pm_narrow_with_sender_typing:start"), | ||
case(set(), id="in_pm_narrow_with_sender_typing:stop"), | ||
case( | ||
{"[email protected]", "[email protected]"}, | ||
id="in_group_pm_narrow_1_member_active", | ||
), | ||
case( | ||
{"[email protected]", "[email protected]"}, | ||
id="in_group_pm_where_3_members_active", | ||
), | ||
case( | ||
{"[email protected]", "[email protected]", "[email protected]"}, | ||
id="in_group_pm_where_4_members_active", | ||
), | ||
], | ||
) | ||
def test_show_typing_notification( | ||
|
@@ -568,7 +580,16 @@ def test_show_typing_notification( | |
setattr( | ||
controller.model, | ||
USER_DICT, | ||
{"[email protected]": {"full_name": "hamlet"}}, | ||
{ | ||
"[email protected]": {"full_name": "hamlet"}, | ||
"[email protected]": {"full_name": "iago"}, | ||
"[email protected]": {"full_name": "verona"}, | ||
"[email protected]": {"full_name": "fan"}, | ||
}, | ||
) | ||
length = len(active_conversation_info) | ||
active_conversation_info = ", ".join( | ||
controller.model.user_dict[x]["full_name"] for x in active_conversation_info | ||
) | ||
|
||
def mock_typing() -> None: | ||
|
@@ -578,35 +599,94 @@ def mock_typing() -> None: | |
Thread(controller.show_typing_notification()).start() | ||
|
||
if active_conversation_info: | ||
set_footer_text.assert_has_calls( | ||
[ | ||
mocker.call( | ||
[ | ||
("footer_contrast", "hamlet "), | ||
("footer", " is typing"), | ||
] | ||
), | ||
mocker.call( | ||
[ | ||
("footer_contrast", "hamlet "), | ||
("footer", " is typing."), | ||
] | ||
), | ||
mocker.call( | ||
[ | ||
("footer_contrast", "hamlet "), | ||
("footer", " is typing.."), | ||
] | ||
), | ||
mocker.call( | ||
[ | ||
("footer_contrast", "hamlet "), | ||
("footer", " is typing..."), | ||
] | ||
), | ||
] | ||
) | ||
set_footer_text.assert_called_with() | ||
if length == 1: | ||
set_footer_text.assert_has_calls( | ||
[ | ||
mocker.call( | ||
[ | ||
("footer_contrast", f"{active_conversation_info} "), | ||
("footer", " is typing"), | ||
] | ||
), | ||
mocker.call( | ||
[ | ||
("footer_contrast", f"{active_conversation_info} "), | ||
("footer", " is typing."), | ||
] | ||
), | ||
mocker.call( | ||
[ | ||
("footer_contrast", f"{active_conversation_info} "), | ||
("footer", " is typing.."), | ||
] | ||
), | ||
mocker.call( | ||
[ | ||
("footer_contrast", f"{active_conversation_info} "), | ||
("footer", " is typing..."), | ||
] | ||
), | ||
] | ||
) | ||
elif length < 4: | ||
set_footer_text.assert_has_calls( | ||
[ | ||
mocker.call( | ||
[ | ||
("footer_contrast", f"{active_conversation_info} "), | ||
("footer", " are typing"), | ||
] | ||
), | ||
mocker.call( | ||
[ | ||
("footer_contrast", f"{active_conversation_info} "), | ||
("footer", " are typing."), | ||
] | ||
), | ||
mocker.call( | ||
[ | ||
("footer_contrast", f"{active_conversation_info} "), | ||
("footer", " are typing.."), | ||
] | ||
), | ||
mocker.call( | ||
[ | ||
("footer_contrast", f"{active_conversation_info} "), | ||
("footer", " are typing..."), | ||
] | ||
), | ||
] | ||
) | ||
else: | ||
set_footer_text.assert_has_calls( | ||
[ | ||
mocker.call( | ||
[ | ||
("footer_contrast", "Multiple people "), | ||
("footer", " are typing"), | ||
] | ||
), | ||
mocker.call( | ||
[ | ||
("footer_contrast", "Multiple people "), | ||
("footer", " are typing."), | ||
] | ||
), | ||
mocker.call( | ||
[ | ||
("footer_contrast", "Multiple people "), | ||
("footer", " are typing.."), | ||
] | ||
), | ||
mocker.call( | ||
[ | ||
("footer_contrast", "Multiple people "), | ||
("footer", " is typing..."), | ||
] | ||
), | ||
] | ||
) | ||
set_footer_text.assert_called_with() | ||
else: | ||
set_footer_text.assert_called_once_with() | ||
assert controller.is_typing_notification_in_progress is False | ||
|