-
-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test_model: Added tests for _handle_typing_event.
Added a new parameter of current active_conversation_info. Constructed a user_dict get full_names out of emails present in active_converstation_info.
- Loading branch information
Subhasish-Behera
committed
Apr 14, 2023
1 parent
1c6a648
commit 06cb1ec
Showing
1 changed file
with
140 additions
and
2 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 |
---|---|---|
|
@@ -2888,6 +2888,7 @@ def test_toggle_stream_visual_notifications( | |
@pytest.mark.parametrize( | ||
( | ||
"narrow, event, is_notification_in_progress," | ||
"current_active_conversation_info," | ||
"expected_active_conversation_info, expected_show_typing_notification," | ||
), | ||
[ | ||
|
@@ -2899,6 +2900,7 @@ def test_toggle_stream_visual_notifications( | |
"id": 0, | ||
}, | ||
False, | ||
set(), | ||
{}, | ||
False, | ||
id="not_in_pm_narrow", | ||
|
@@ -2915,6 +2917,7 @@ def test_toggle_stream_visual_notifications( | |
"id": 0, | ||
}, | ||
False, | ||
set(), | ||
{}, | ||
False, | ||
id="not_in_pm_narrow_with_sender", | ||
|
@@ -2931,6 +2934,7 @@ def test_toggle_stream_visual_notifications( | |
"id": 0, | ||
}, | ||
False, | ||
set(), | ||
{"[email protected]"}, | ||
True, | ||
id="in_pm_narrow_with_sender_typing:start", | ||
|
@@ -2947,6 +2951,7 @@ def test_toggle_stream_visual_notifications( | |
"id": 0, | ||
}, | ||
True, | ||
set(), | ||
{"[email protected]"}, | ||
False, | ||
id="in_pm_narrow_with_sender_typing:start_while_animation_in_progress", | ||
|
@@ -2963,6 +2968,7 @@ def test_toggle_stream_visual_notifications( | |
"id": 0, | ||
}, | ||
True, | ||
set(), | ||
{}, | ||
False, | ||
id="in_pm_narrow_with_sender_typing:stop", | ||
|
@@ -2979,6 +2985,7 @@ def test_toggle_stream_visual_notifications( | |
"id": 0, | ||
}, | ||
False, | ||
set(), | ||
{}, | ||
False, | ||
id="in_pm_narrow_with_other_myself_typing:start", | ||
|
@@ -2995,6 +3002,7 @@ def test_toggle_stream_visual_notifications( | |
"id": 0, | ||
}, | ||
False, | ||
set(), | ||
{}, | ||
False, | ||
id="in_pm_narrow_with_other_myself_typing:stop", | ||
|
@@ -3008,6 +3016,7 @@ def test_toggle_stream_visual_notifications( | |
"id": 0, | ||
}, | ||
False, | ||
set(), | ||
{}, | ||
False, | ||
id="in_pm_narrow_with_oneself:start", | ||
|
@@ -3021,10 +3030,131 @@ def test_toggle_stream_visual_notifications( | |
"id": 0, | ||
}, | ||
False, | ||
set(), | ||
{}, | ||
False, | ||
id="in_pm_narrow_with_oneself:stop", | ||
), | ||
case( | ||
[ | ||
[ | ||
"pm_with", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
] | ||
], | ||
{ | ||
"op": "start", | ||
"sender": {"user_id": 4, "email": "[email protected]"}, | ||
"recipients": [ | ||
{"user_id": 4, "email": "[email protected]"}, | ||
{"user_id": 5, "email": "[email protected]"}, | ||
], | ||
"id": 0, | ||
}, | ||
False, | ||
set(), | ||
{"[email protected]"}, | ||
True, | ||
id="in_group_pm_narrow_with_sender_typing:start", | ||
), | ||
case( | ||
[ | ||
[ | ||
"pm_with", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
] | ||
], | ||
{ | ||
"op": "stop", | ||
"sender": {"user_id": 4, "email": "[email protected]"}, | ||
"recipients": [ | ||
{"user_id": 4, "email": "[email protected]"}, | ||
{"user_id": 5, "email": "[email protected]"}, | ||
], | ||
"id": 0, | ||
}, | ||
True, | ||
{"[email protected]"}, | ||
{}, | ||
False, | ||
id="in_group_pm_narrow,sender_typing:stop" | ||
"_while animation is in progress", | ||
), | ||
case( | ||
[["pm_with", "[email protected], [email protected]"]], | ||
{ | ||
"op": "start", | ||
"sender": {"user_id": 6, "email": "[email protected]"}, | ||
"recipients": [ | ||
{"user_id": 4, "email": "[email protected]"}, | ||
{"user_id": 6, "email": "[email protected]"}, | ||
], | ||
"id": 0, | ||
}, | ||
True, | ||
{"[email protected]"}, | ||
{"[email protected]", "[email protected]"}, | ||
False, | ||
id="in_group_pm_narrow,second_sender_typing:start" | ||
"_while animation in progress", | ||
), | ||
case( | ||
[["pm_with", "[email protected], [email protected]"]], | ||
{ | ||
"op": "stop", | ||
"sender": {"user_id": 6, "email": "[email protected]"}, | ||
"recipients": [ | ||
{"user_id": 4, "email": "[email protected]"}, | ||
{"user_id": 6, "email": "[email protected]"}, | ||
], | ||
"id": 0, | ||
}, | ||
True, | ||
{"[email protected]", "[email protected]"}, | ||
{"[email protected]"}, | ||
False, | ||
id="in_group_pm_narrow,second_sender_typing:stop" | ||
"_while animation in progress", | ||
), | ||
case( | ||
[["pm_with", "[email protected], [email protected],[email protected]"]], | ||
{ | ||
"op": "start", | ||
"sender": {"user_id": 5, "email": "[email protected]"}, | ||
"recipients": [ | ||
{"user_id": 4, "email": "[email protected]"}, | ||
{"user_id": 6, "email": "[email protected]"}, | ||
], | ||
"id": 0, | ||
}, | ||
True, | ||
{"[email protected]", "[email protected]"}, | ||
{"[email protected]", "[email protected]"}, | ||
False, | ||
id="in_group_pm_narrow,user_typing:start" | ||
"_while animation in progress", | ||
), | ||
case( | ||
[["pm_with", "[email protected], [email protected],[email protected]"]], | ||
{ | ||
"op": "stop", | ||
"sender": {"user_id": 5, "email": "[email protected]"}, | ||
"recipients": [ | ||
{"user_id": 4, "email": "[email protected]"}, | ||
{"user_id": 6, "email": "[email protected]"}, | ||
], | ||
"id": 0, | ||
}, | ||
True, | ||
{"[email protected]", "[email protected]"}, | ||
{"[email protected]", "[email protected]"}, | ||
False, | ||
id="in_group_pm_narrow,usertyping:stop_" "while animation in progress", | ||
), | ||
], | ||
) | ||
def test__handle_typing_event( | ||
|
@@ -3034,17 +3164,25 @@ def test__handle_typing_event( | |
narrow, | ||
event, | ||
is_notification_in_progress, | ||
current_active_conversation_info, | ||
expected_active_conversation_info, | ||
expected_show_typing_notification, | ||
): | ||
event["type"] = "typing" | ||
|
||
model.narrow = narrow | ||
model.user_dict = { | ||
"[email protected]": {"full_name": "hamlet", "email": "[email protected]"} | ||
"[email protected]": {"full_name": "hamlet", "email": "[email protected]"}, | ||
"[email protected]": {"full_name": "macbeth", "email": "[email protected]"}, | ||
"[email protected]": {"full_name": "iag0", "email": "[email protected]"}, | ||
"[email protected]": {"full_name": "verona", "email": "[email protected]"}, | ||
"[email protected]": { | ||
"full_name": "claudius", | ||
"email": "[email protected]", | ||
}, | ||
} | ||
model.user_id = 5 # Iago's user_id | ||
model.controller.active_conversation_info = set() | ||
model.controller.active_conversation_info = current_active_conversation_info | ||
model.controller.is_typing_notification_in_progress = ( | ||
is_notification_in_progress | ||
) | ||
|