|
7 | 7 | from pytest import param as case
|
8 | 8 | from zulip import Client, ZulipError
|
9 | 9 |
|
| 10 | +from zulipterminal.api_types import RESOLVED_TOPIC_PREFIX |
10 | 11 | from zulipterminal.config.symbols import STREAM_TOPIC_SEPARATOR
|
11 | 12 | from zulipterminal.helper import initial_index, powerset
|
12 | 13 | from zulipterminal.model import (
|
@@ -1198,6 +1199,77 @@ def test_can_user_edit_topic(
|
1198 | 1199 | else:
|
1199 | 1200 | report_error.assert_called_once_with(expected_response[user_type][0])
|
1200 | 1201 |
|
| 1202 | + @pytest.mark.parametrize( |
| 1203 | + "topic_name, msg_response, server_feature_level, return_value, expect_footer_error", |
| 1204 | + [ |
| 1205 | + ( |
| 1206 | + "hi!", |
| 1207 | + { |
| 1208 | + "subject": "hi!", |
| 1209 | + "timestamp": 11662271397, |
| 1210 | + "id": 1, |
| 1211 | + }, |
| 1212 | + 12, |
| 1213 | + RESOLVED_TOPIC_PREFIX + "hi!", |
| 1214 | + False, |
| 1215 | + ), |
| 1216 | + ( |
| 1217 | + "hi!", |
| 1218 | + { |
| 1219 | + "subject": "hi!", |
| 1220 | + "timestamp": 0, |
| 1221 | + "id": 1, |
| 1222 | + }, |
| 1223 | + None, |
| 1224 | + " Time limit for editing topic has been exceeded.", |
| 1225 | + True, |
| 1226 | + ), |
| 1227 | + ( |
| 1228 | + "✔ hi!", |
| 1229 | + { |
| 1230 | + "subject": "✔ hi!", |
| 1231 | + "timestamp": 11662271397, |
| 1232 | + "id": 1, |
| 1233 | + }, |
| 1234 | + 10, |
| 1235 | + "hi!", |
| 1236 | + False, |
| 1237 | + ), |
| 1238 | + ], |
| 1239 | + ) |
| 1240 | + def test_un_resolve_topic( |
| 1241 | + self, |
| 1242 | + mocker, |
| 1243 | + model, |
| 1244 | + initial_data, |
| 1245 | + topic_name, |
| 1246 | + msg_response, |
| 1247 | + server_feature_level, |
| 1248 | + return_value, |
| 1249 | + expect_footer_error, |
| 1250 | + stream_id=1, |
| 1251 | + ): |
| 1252 | + model.initial_data = initial_data |
| 1253 | + model.server_feature_level = server_feature_level |
| 1254 | + initial_data["realm_community_topic_editing_limit_seconds"] = 86400 |
| 1255 | + # If user can't edit topic, topic (un)resolve is disabled. Therefore, |
| 1256 | + # default return_value=True |
| 1257 | + model.can_user_edit_topic = mocker.Mock(return_value=True) |
| 1258 | + model.get_latest_message_in_topic = mocker.Mock(return_value=msg_response) |
| 1259 | + model.update_stream_message = mocker.Mock(return_value={"result": "success"}) |
| 1260 | + report_error = model.controller.report_error |
| 1261 | + |
| 1262 | + model.un_resolve_topic(stream_id, topic_name) |
| 1263 | + |
| 1264 | + if not expect_footer_error: |
| 1265 | + model.update_stream_message.assert_called_once_with( |
| 1266 | + message_id=msg_response["id"], |
| 1267 | + topic=return_value, |
| 1268 | + propagate_mode="change_all", |
| 1269 | + ) |
| 1270 | + else: |
| 1271 | + report_error.assert_called_once_with(return_value) |
| 1272 | + |
1201 | 1273 | # NOTE: This tests only getting next-unread, not a fixed anchor
|
1202 | 1274 | def test_success_get_messages(
|
1203 | 1275 | self,
|
|
0 commit comments