def test_update_flag(mocker: Any) -> None: mock_controller = mocker.patch('zulipterminal.core.Controller') mock_api_query = mocker.patch('zulipterminal.core.Controller' '.client.do_api_query') update_flag([1, 2], mock_controller) mock_api_query.assert_called_once_with( {'flag': 'read', 'messages': [1, 2], 'op': 'add'}, '/json/messages/flags', method='POST' )
def test_update_flag(mocker): mock_client = mocker.patch('zulip.Client') mock_api_query = mocker.patch('zulip.Client.do_api_query') update_flag([1, 2], mock_client) mock_api_query.assert_called_once_with( { 'flag': 'read', 'messages': [1, 2], 'op': 'add' }, '/json/messages/flags', method='POST')
def read_message(self): # Message currently in focus msg_w, curr_pos = self.body.get_focus() if msg_w is None: return # msg ids that have been read read_msg_ids = list() # type: List[int] # until we find a read message above the current message while msg_w.original_widget.message['color'] == 'unread': read_msg_ids.append(msg_w.original_widget.message['id']) msg_w.set_attr_map({None: None}) msg_w, curr_pos = self.body.get_prev(curr_pos) if msg_w is None: break update_flag(read_msg_ids, self.model.controller.client)
def read_message(self) -> None: # Message currently in focus msg_w, curr_pos = self.body.get_focus() if msg_w is None: return self.update_search_box_narrow(msg_w.original_widget) # save the current focus self.model.set_focus_in_current_narrow(self.focus_position) # msg ids that have been read read_msg_ids = list() # type: List[int] # until we find a read message above the current message while msg_w.attr_map == {None: 'unread'}: msg_id = msg_w.original_widget.message['id'] read_msg_ids.append(msg_id) self.model.index['messages'][msg_id]['flags'].append('read') msg_w.set_attr_map({None: None}) msg_w, curr_pos = self.body.get_prev(curr_pos) if msg_w is None: break update_flag(read_msg_ids, self.model.controller)
def test_update_flag_empty_msg_list(mocker): assert update_flag([], mocker.patch('zulip.Client')) is None