@@ -468,6 +468,7 @@ def mock_external_classes(self, mocker: MockerFixture, msg_box: MessageBox) -> N
468
468
topic_links = OrderedDict (),
469
469
message_links = OrderedDict (),
470
470
time_mentions = list (),
471
+ code_blocks = list (),
471
472
title = "Full Rendered Message" ,
472
473
)
473
474
@@ -520,6 +521,7 @@ def test_keypress_show_msg_info(
520
521
topic_links = OrderedDict (),
521
522
message_links = OrderedDict (),
522
523
time_mentions = list (),
524
+ code_blocks = list (),
523
525
)
524
526
525
527
@@ -544,6 +546,7 @@ def mock_external_classes(self, mocker: MockerFixture, msg_box: MessageBox) -> N
544
546
topic_links = OrderedDict (),
545
547
message_links = OrderedDict (),
546
548
time_mentions = list (),
549
+ code_blocks = list (),
547
550
title = "Full Raw Message" ,
548
551
)
549
552
@@ -596,6 +599,7 @@ def test_keypress_show_msg_info(
596
599
topic_links = OrderedDict (),
597
600
message_links = OrderedDict (),
598
601
time_mentions = list (),
602
+ code_blocks = list (),
599
603
)
600
604
601
605
@@ -619,6 +623,7 @@ def mock_external_classes(self, mocker: MockerFixture) -> None:
619
623
topic_links = OrderedDict (),
620
624
message_links = OrderedDict (),
621
625
time_mentions = list (),
626
+ code_blocks = list (),
622
627
title = "Edit History" ,
623
628
)
624
629
@@ -667,6 +672,7 @@ def test_keypress_show_msg_info(
667
672
topic_links = OrderedDict (),
668
673
message_links = OrderedDict (),
669
674
time_mentions = list (),
675
+ code_blocks = list (),
670
676
)
671
677
672
678
@pytest .mark .parametrize (
@@ -944,6 +950,7 @@ def mock_external_classes(
944
950
OrderedDict (),
945
951
OrderedDict (),
946
952
list (),
953
+ list (),
947
954
)
948
955
949
956
def test_init (self , message_fixture : Message ) -> None :
@@ -962,6 +969,7 @@ def test_pop_up_info_order(self, message_fixture: Message) -> None:
962
969
topic_links = topic_links ,
963
970
message_links = message_links ,
964
971
time_mentions = list (),
972
+ code_blocks = list (),
965
973
)
966
974
msg_links = msg_info_view .button_widgets
967
975
assert msg_links == [message_links , topic_links ]
@@ -1010,6 +1018,7 @@ def test_keypress_edit_history(
1010
1018
topic_links = OrderedDict (),
1011
1019
message_links = OrderedDict (),
1012
1020
time_mentions = list (),
1021
+ code_blocks = list (),
1013
1022
)
1014
1023
size = widget_size (msg_info_view )
1015
1024
@@ -1021,6 +1030,7 @@ def test_keypress_edit_history(
1021
1030
topic_links = OrderedDict (),
1022
1031
message_links = OrderedDict (),
1023
1032
time_mentions = list (),
1033
+ code_blocks = list (),
1024
1034
)
1025
1035
else :
1026
1036
self .controller .show_edit_history .assert_not_called ()
@@ -1039,6 +1049,7 @@ def test_keypress_full_rendered_message(
1039
1049
topic_links = OrderedDict (),
1040
1050
message_links = OrderedDict (),
1041
1051
time_mentions = list (),
1052
+ code_blocks = list (),
1042
1053
)
1043
1054
size = widget_size (msg_info_view )
1044
1055
@@ -1049,6 +1060,7 @@ def test_keypress_full_rendered_message(
1049
1060
topic_links = OrderedDict (),
1050
1061
message_links = OrderedDict (),
1051
1062
time_mentions = list (),
1063
+ code_blocks = list (),
1052
1064
)
1053
1065
1054
1066
@pytest .mark .parametrize ("key" , keys_for_command ("FULL_RAW_MESSAGE" ))
@@ -1065,6 +1077,7 @@ def test_keypress_full_raw_message(
1065
1077
topic_links = OrderedDict (),
1066
1078
message_links = OrderedDict (),
1067
1079
time_mentions = list (),
1080
+ code_blocks = list (),
1068
1081
)
1069
1082
size = widget_size (msg_info_view )
1070
1083
@@ -1075,6 +1088,7 @@ def test_keypress_full_raw_message(
1075
1088
topic_links = OrderedDict (),
1076
1089
message_links = OrderedDict (),
1077
1090
time_mentions = list (),
1091
+ code_blocks = list (),
1078
1092
)
1079
1093
1080
1094
@pytest .mark .parametrize (
@@ -1176,6 +1190,7 @@ def test_height_reactions(
1176
1190
OrderedDict (),
1177
1191
OrderedDict (),
1178
1192
list (),
1193
+ list (),
1179
1194
)
1180
1195
# 12 = 7 labels + 2 blank lines + 1 'Reactions' (category)
1181
1196
# + 4 reactions (excluding 'Message Links').
@@ -1229,6 +1244,118 @@ def test_create_link_buttons(
1229
1244
assert link_w ._wrapped_widget .attr_map == expected_attr_map
1230
1245
assert link_width == expected_link_width
1231
1246
1247
+ @pytest .mark .parametrize (
1248
+ [
1249
+ "initial_code_block" ,
1250
+ "expected_code" ,
1251
+ "expected_attr_map" ,
1252
+ "expected_focus_map" ,
1253
+ ],
1254
+ [
1255
+ (
1256
+ [
1257
+ (
1258
+ "Python" ,
1259
+ [
1260
+ ("pygments:k" , "def" ),
1261
+ ("pygments:w" , " " ),
1262
+ ("pygments:nf" , "main" ),
1263
+ ("pygments:p" , "()" ),
1264
+ ("pygments:w" , "\n " ),
1265
+ ("pygments:nb" , "print" ),
1266
+ ("pygments:p" , "(" ),
1267
+ ("pygments:s2" , '"Hello"' ),
1268
+ ("pygments:p" , ")" ),
1269
+ ("pygments:w" , "\n " ),
1270
+ ],
1271
+ )
1272
+ ],
1273
+ '1: Python\n def main()\n print("Hello")...' ,
1274
+ {None : "popup_contrast" },
1275
+ {None : "selected" },
1276
+ ),
1277
+ (
1278
+ [
1279
+ (
1280
+ "JavaScript" ,
1281
+ [
1282
+ ("pygments:nx" , "console" ),
1283
+ ("pygments:p" , "." ),
1284
+ ("pygments:nx" , "log" ),
1285
+ ("pygments:p" , "(" ),
1286
+ ("pygments:s2" , '"Hello, world!"' ),
1287
+ ("pygments:p" , ");" ),
1288
+ ("pygments:w" , "\n " ),
1289
+ ],
1290
+ )
1291
+ ],
1292
+ '1: JavaScript\n console.log("Hello, world!");' ,
1293
+ {None : "popup_contrast" },
1294
+ {None : "selected" },
1295
+ ),
1296
+ (
1297
+ [
1298
+ (
1299
+ "C++" ,
1300
+ [
1301
+ ("pygments:cp" , "#include" ),
1302
+ ("pygments:w" , " " ),
1303
+ ("pygments:cpf" , "<iostream>" ),
1304
+ ("pygments:w" , "\n \n " ),
1305
+ ("pygments:kt" , "int" ),
1306
+ ("pygments:w" , " " ),
1307
+ ("pygments:nf" , "main" ),
1308
+ ("pygments:p" , "()" ),
1309
+ ("pygments:w" , " " ),
1310
+ ("pygments:p" , "{" ),
1311
+ ("pygments:w" , "\n " ),
1312
+ ("pygments:w" , " " ),
1313
+ ("pygments:n" , "std" ),
1314
+ ("pygments:o" , "::" ),
1315
+ ("pygments:n" , "cout" ),
1316
+ ("pygments:w" , " " ),
1317
+ ("pygments:o" , "<<" ),
1318
+ ("pygments:w" , " " ),
1319
+ ("pygments:s" , '"Hello World!"' ),
1320
+ ("pygments:p" , ";" ),
1321
+ ("pygments:w" , "\n " ),
1322
+ ("pygments:w" , " " ),
1323
+ ("pygments:k" , "return" ),
1324
+ ("pygments:w" , " " ),
1325
+ ("pygments:mi" , "0" ),
1326
+ ("pygments:p" , ";" ),
1327
+ ("pygments:w" , "\n " ),
1328
+ ("pygments:p" , "}" ),
1329
+ ("pygments:w" , "\n " ),
1330
+ ],
1331
+ )
1332
+ ],
1333
+ "1: C++\n #include <iostream>\n \n int main() {..." ,
1334
+ {None : "popup_contrast" },
1335
+ {None : "selected" },
1336
+ ),
1337
+ ],
1338
+ ids = [
1339
+ "with_python_code_block_two_lines" ,
1340
+ "with_javascript_code_block_one_line" ,
1341
+ "with_cpp_code_block_more_than_two_lines" ,
1342
+ ],
1343
+ )
1344
+ def test_create_code_block_buttons (
1345
+ self ,
1346
+ initial_code_block : List [Tuple [str , List [Tuple [str , str ]]]],
1347
+ expected_code : str ,
1348
+ expected_attr_map : Dict [None , str ],
1349
+ expected_focus_map : Dict [None , str ],
1350
+ ) -> None :
1351
+ [code_w ], _ = self .msg_info_view .create_code_block_buttons (
1352
+ self .controller , initial_code_block
1353
+ )
1354
+
1355
+ assert code_w ._wrapped_widget .original_widget .text == expected_code
1356
+ assert code_w ._wrapped_widget .focus_map == expected_focus_map
1357
+ assert code_w ._wrapped_widget .attr_map == expected_attr_map
1358
+
1232
1359
1233
1360
class TestStreamInfoView :
1234
1361
@pytest .fixture (autouse = True )
0 commit comments