Skip to content

Commit 08d2a32

Browse files
committed
tests: helper: Test set_count for muted streams.
Add test for verifying unread_counts when marking muted streams read/unread. The 'all_msg' attribute in unread counts does not change while changing the read status of such messages.
1 parent 675a180 commit 08d2a32

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/helper/test_helper.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,44 @@ def test_set_count_group_pms(mocker, initial_unread_counts, all_msg, new_count,
116116
assert controller.model.unread_counts == expected_unread_counts
117117

118118

119+
@pytest.mark.parametrize('all_msg, unread_topics', [
120+
(6, {(1001, 'Topic 1'): 3, (1002, 'Topic 3'): 1, (1003, 'Topic 10'): 2}),
121+
])
122+
@pytest.mark.parametrize(
123+
'new_count, expected_unread_topics, id_list, muted_streams,\
124+
expected_all_msg', [
125+
(1, {(1001, 'Topic 1'): 4, (1002, 'Topic 3'): 1,
126+
(1003, 'Topic 10'): 4}, [7, 8, 9], [1001, 1003], 6,),
127+
(1, {(1001, 'Topic 1'): 4, (1002, 'Topic 3'): 1,
128+
(1003, 'Topic 10'): 4}, [7, 8, 9], [1001, 1002, 1003], 6, ),
129+
(1, {(1001, 'Topic 1'): 4, (1002, 'Topic 3'): 2,
130+
(1003, 'Topic 10'): 4}, [7, 8, 9, 4], [1001, 1003], 7, ),
131+
(-1, {(1001, 'Topic 1'): 2, (1002, 'Topic 3'): 1,
132+
(1003, 'Topic 10'): 2}, [2], [1001], 6, ),
133+
(-1, {(1001, 'Topic 1'): 2, (1003, 'Topic 10'): 2}, [2, 4], [1001], 5, ),
134+
])
135+
def test_set_count_muted_streams(mocker, initial_unread_counts, muted_streams,
136+
unread_topics, all_msg, id_list, new_count,
137+
expected_unread_topics, expected_all_msg,
138+
index_multiple_messages):
139+
# all_msg does not change for muted streams.
140+
controller = mocker.patch('zulipterminal.core.Controller.__init__')
141+
controller.model.index = index_multiple_messages
142+
controller.model.is_muted_stream = lambda stream_id: \
143+
stream_id in muted_streams
144+
controller.view.left_panel.is_in_topic_view = False
145+
146+
unread_counts = deepcopy(dict(initial_unread_counts,
147+
**{'all_msg': all_msg,
148+
'unread_topics': unread_topics}))
149+
expected_unread_counts = dict(initial_unread_counts,
150+
**{'all_msg': expected_all_msg,
151+
'unread_topics': expected_unread_topics})
152+
controller.model.unread_counts = unread_counts
153+
set_count(id_list, controller, new_count)
154+
assert controller.model.unread_counts == expected_unread_counts
155+
156+
119157
def test_index_messages_narrow_all_messages(mocker,
120158
messages_successful_response,
121159
index_all_messages,

0 commit comments

Comments
 (0)