Skip to content

Commit d5444ed

Browse files
committed
model/test_model: Tests amended.
Previously `test_model` was failing because of missing parameter. This has been fixed now. Also, a bug in the logic of footer notification when sending a message outside of current narrow is fixed.
1 parent 3625132 commit d5444ed

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

tests/model/test_model.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -811,33 +811,35 @@ def test__handle_message_event_with_flags(self, mocker,
811811

812812
@pytest.mark.parametrize('response, narrow, recipients, log', [
813813
({'type': 'stream', 'stream_id': 1, 'subject': 'FOO',
814-
'id': 1}, [], frozenset(), ['msg_w']),
815-
({'type': 'private', 'id': 1},
814+
'id': 1, 'sender_id': 1, 'display_recipient': 'a'},
815+
[], frozenset(), ['msg_w']),
816+
({'type': 'private', 'id': 1, 'sender_id': 1, 'subject': 'FOO',
817+
'display_recipient': 'a'},
816818
[['is', 'private']], frozenset(), ['msg_w']),
817819
({'type': 'stream', 'id': 1, 'stream_id': 1, 'subject': 'FOO',
818-
'display_recipient': 'a'},
820+
'display_recipient': 'a', 'sender_id': 1},
819821
[['stream', 'a']], frozenset(), ['msg_w']),
820822
({'type': 'stream', 'id': 1, 'stream_id': 1, 'subject': 'b',
821-
'display_recipient': 'a'},
823+
'display_recipient': 'a', 'sender_id': 1},
822824
[['stream', 'a'], ['topic', 'b']],
823825
frozenset(), ['msg_w']),
824826
({'type': 'stream', 'id': 1, 'stream_id': 1, 'subject': 'b',
825-
'display_recipient': 'a'},
827+
'display_recipient': 'a', 'sender_id': 1},
826828
[['stream', 'c'], ['topic', 'b']],
827829
frozenset(), []),
828-
({'type': 'private', 'id': 1,
830+
({'type': 'private', 'id': 1, 'sender_id': 1, 'subject': 'FOO',
829831
'display_recipient': [{'id': 5827}, {'id': 5}]},
830832
[['pm_with', 'notification-bot@zulip.com']],
831833
frozenset({5827, 5}), ['msg_w']),
832-
({'type': 'private', 'id': 1},
833-
[['is', 'search']],
834+
({'type': 'private', 'id': 1, 'sender_id': 1, 'subject': 'FOO',
835+
'display_recipient': 'a'}, [['is', 'search']],
834836
frozenset(), []),
835-
({'type': 'private', 'id': 1,
837+
({'type': 'private', 'id': 1, 'sender_id': 1, 'subject': 'FOO',
836838
'display_recipient': [{'id': 5827}, {'id': 3212}]},
837839
[['pm_with', 'notification-bot@zulip.com']],
838840
frozenset({5827, 5}), []),
839841
({'type': 'stream', 'id': 1, 'stream_id': 1, 'subject': 'c',
840-
'display_recipient': 'a', 'flags': ['mentioned']},
842+
'display_recipient': 'a', 'sender_id': 1, 'flags': ['mentioned']},
841843
[['is', 'mentioned']], frozenset(), ['msg_w']),
842844
], ids=['stream_to_all_messages', 'private_to_all_private',
843845
'stream_to_stream', 'stream_to_topic',

zulipterminal/model.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -976,15 +976,16 @@ def _handle_message_event(self, event: Event) -> None:
976976
if narrow_recipients == message_recipients:
977977
msg_log.append(msg_w)
978978

979-
print("message_sender_id =>",message['sender_id'], flush=True)
980-
print("user_id =>",self.user_id, flush=True)
979+
print("message =>", message, flush=True)
980+
print("message_sender_id =>", message['sender_id'], flush=True)
981+
print("user_id =>", self.user_id, flush=True)
981982
print("message_type =>", message['type'], flush=True)
982983
print("message_subject =>", message['subject'], flush=True)
983984
if (((len(self.narrow) == 1
984-
and self.narrow[0][1] != message['type'])
985+
and self.narrow[0][1] != message['display_recipient'])
985986
or (len(self.narrow) == 2
986987
and self.narrow[1][1] != message['subject']))
987-
and message['sender_id'] == self.user_id):
988+
and message['sender_id'] == self.user_id):
988989
self.controller.view.set_footer_text(
989990
'Message sent outside of current narrow', 3)
990991

0 commit comments

Comments
 (0)