@@ -686,7 +686,8 @@ class TestUsersView:
686
686
@pytest .fixture
687
687
def user_view (self , mocker ):
688
688
mocker .patch (VIEWS + ".urwid.SimpleFocusListWalker" , return_value = [])
689
- return UsersView ("USER_BTN_LIST" )
689
+ controller = mocker .Mock ()
690
+ return UsersView (controller , "USER_BTN_LIST" )
690
691
691
692
def test_mouse_event (self , mocker , user_view ):
692
693
mocker .patch .object (user_view , 'keypress' )
@@ -702,15 +703,32 @@ def test_mouse_event(self, mocker, user_view):
702
703
user_view .mouse_event (size , "mouse press" , 5 , col , row , focus )
703
704
user_view .keypress .assert_called_with (size , "down" )
704
705
706
+ @pytest .mark .parametrize ('compose_box_open' , [True , False ])
707
+ def test_mouse_event_left_click (self , mocker , user_view ,
708
+ compose_box_open ):
709
+ super_mouse_event = mocker .patch (
710
+ 'zulipterminal.ui.urwid.ListBox.mouse_event' )
711
+ user_view .controller .is_in_editor_mode .return_value = (
712
+ compose_box_open
713
+ )
714
+ size = (20 , )
715
+ focus = mocker .Mock ()
716
+
717
+ user_view .mouse_event (size , 'mouse press' , 1 , 1 , 1 , focus )
718
+
719
+ if compose_box_open :
720
+ super_mouse_event .assert_not_called ()
721
+ else :
722
+ super_mouse_event .assert_called_once_with (size , 'mouse press' , 1 ,
723
+ 1 , 1 , focus )
724
+
705
725
@pytest .mark .parametrize ('event, button' , [
706
726
('mouse release' , 0 ),
707
- ('mouse press' , 1 ),
708
727
('mouse press' , 3 ),
709
728
('mouse release' , 4 ),
710
729
],
711
730
ids = [
712
731
'unsupported_mouse_release_action' ,
713
- 'unsupported_left_click_mouse_press_action' ,
714
732
'unsupported_right_click_mouse_press_action' ,
715
733
'invalid_event_button_combination' ,
716
734
]
@@ -1048,7 +1066,8 @@ def test_users_view(self, users, users_btn_len, editor_mode, status,
1048
1066
color = 'user_' + self .view .users [0 ]['status' ],
1049
1067
count = 1
1050
1068
)
1051
- users_view .assert_called_once_with (right_col_view .users_btn_list )
1069
+ users_view .assert_called_once_with (self .view .controller ,
1070
+ right_col_view .users_btn_list )
1052
1071
assert len (right_col_view .users_btn_list ) == users_btn_len
1053
1072
1054
1073
@pytest .mark .parametrize ('key' , keys_for_command ('SEARCH_PEOPLE' ))
@@ -2248,21 +2267,30 @@ def test_footlinks_view(self, message_fixture, message_links,
2248
2267
assert footlinks is None
2249
2268
assert not hasattr (footlinks , 'original_widget' )
2250
2269
2270
+ @pytest .mark .parametrize ('compose_box_open' , [True , False ])
2251
2271
@pytest .mark .parametrize (
2252
2272
'key' , keys_for_command ('ENTER' ),
2253
2273
ids = lambda param : 'left_click-key:{}' .format (param )
2254
2274
)
2255
- def test_mouse_event_left_click (self , mocker , msg_box , key ):
2275
+ def test_mouse_event_left_click (self , mocker , msg_box , key ,
2276
+ compose_box_open ):
2256
2277
size = (20 , )
2257
2278
col = 1
2258
2279
row = 1
2259
2280
focus = mocker .Mock ()
2260
2281
mocker .patch (BOXES + '.keys_for_command' , return_value = [key ])
2261
2282
mocker .patch .object (msg_box , 'keypress' )
2283
+ msg_box .model = mocker .Mock ()
2284
+ msg_box .model .controller .is_in_editor_mode .return_value = (
2285
+ compose_box_open
2286
+ )
2262
2287
2263
2288
msg_box .mouse_event (size , 'mouse press' , 1 , col , row , focus )
2264
2289
2265
- msg_box .keypress .assert_called_once_with (size , key )
2290
+ if compose_box_open :
2291
+ msg_box .keypress .assert_not_called ()
2292
+ else :
2293
+ msg_box .keypress .assert_called_once_with (size , key )
2266
2294
2267
2295
2268
2296
class TestTopButton :
0 commit comments