@@ -467,6 +467,7 @@ def mock_external_classes(self, mocker: MockerFixture, msg_box: MessageBox) -> N
467467 message = self .message ,
468468 topic_links = OrderedDict (),
469469 message_links = OrderedDict (),
470+ code_snippets = list (),
470471 time_mentions = list (),
471472 title = "Full Rendered Message" ,
472473 )
@@ -519,6 +520,7 @@ def test_keypress_show_msg_info(
519520 msg = self .message ,
520521 topic_links = OrderedDict (),
521522 message_links = OrderedDict (),
523+ code_snippets = list (),
522524 time_mentions = list (),
523525 )
524526
@@ -543,6 +545,7 @@ def mock_external_classes(self, mocker: MockerFixture, msg_box: MessageBox) -> N
543545 message = self .message ,
544546 topic_links = OrderedDict (),
545547 message_links = OrderedDict (),
548+ code_snippets = list (),
546549 time_mentions = list (),
547550 title = "Full Raw Message" ,
548551 )
@@ -595,6 +598,7 @@ def test_keypress_show_msg_info(
595598 msg = self .message ,
596599 topic_links = OrderedDict (),
597600 message_links = OrderedDict (),
601+ code_snippets = list (),
598602 time_mentions = list (),
599603 )
600604
@@ -618,6 +622,7 @@ def mock_external_classes(self, mocker: MockerFixture) -> None:
618622 message = self .message ,
619623 topic_links = OrderedDict (),
620624 message_links = OrderedDict (),
625+ code_snippets = list (),
621626 time_mentions = list (),
622627 title = "Edit History" ,
623628 )
@@ -666,6 +671,7 @@ def test_keypress_show_msg_info(
666671 msg = self .message ,
667672 topic_links = OrderedDict (),
668673 message_links = OrderedDict (),
674+ code_snippets = list (),
669675 time_mentions = list (),
670676 )
671677
@@ -944,6 +950,7 @@ def mock_external_classes(
944950 OrderedDict (),
945951 OrderedDict (),
946952 list (),
953+ list (),
947954 )
948955
949956 def test_init (self , message_fixture : Message ) -> None :
@@ -961,6 +968,7 @@ def test_pop_up_info_order(self, message_fixture: Message) -> None:
961968 title = "Message Information" ,
962969 topic_links = topic_links ,
963970 message_links = message_links ,
971+ code_snippets = list (),
964972 time_mentions = list (),
965973 )
966974 msg_links = msg_info_view .button_widgets
@@ -1009,6 +1017,7 @@ def test_keypress_edit_history(
10091017 title = "Message Information" ,
10101018 topic_links = OrderedDict (),
10111019 message_links = OrderedDict (),
1020+ code_snippets = list (),
10121021 time_mentions = list (),
10131022 )
10141023 size = widget_size (msg_info_view )
@@ -1020,6 +1029,7 @@ def test_keypress_edit_history(
10201029 message = message_fixture ,
10211030 topic_links = OrderedDict (),
10221031 message_links = OrderedDict (),
1032+ code_snippets = list (),
10231033 time_mentions = list (),
10241034 )
10251035 else :
@@ -1038,6 +1048,7 @@ def test_keypress_full_rendered_message(
10381048 title = "Message Information" ,
10391049 topic_links = OrderedDict (),
10401050 message_links = OrderedDict (),
1051+ code_snippets = list (),
10411052 time_mentions = list (),
10421053 )
10431054 size = widget_size (msg_info_view )
@@ -1048,6 +1059,7 @@ def test_keypress_full_rendered_message(
10481059 message = message_fixture ,
10491060 topic_links = OrderedDict (),
10501061 message_links = OrderedDict (),
1062+ code_snippets = list (),
10511063 time_mentions = list (),
10521064 )
10531065
@@ -1064,6 +1076,7 @@ def test_keypress_full_raw_message(
10641076 title = "Message Information" ,
10651077 topic_links = OrderedDict (),
10661078 message_links = OrderedDict (),
1079+ code_snippets = list (),
10671080 time_mentions = list (),
10681081 )
10691082 size = widget_size (msg_info_view )
@@ -1074,6 +1087,7 @@ def test_keypress_full_raw_message(
10741087 message = message_fixture ,
10751088 topic_links = OrderedDict (),
10761089 message_links = OrderedDict (),
1090+ code_snippets = list (),
10771091 time_mentions = list (),
10781092 )
10791093
@@ -1176,6 +1190,7 @@ def test_height_reactions(
11761190 OrderedDict (),
11771191 OrderedDict (),
11781192 list (),
1193+ list (),
11791194 )
11801195 # 12 = 7 labels + 2 blank lines + 1 'Reactions' (category)
11811196 # + 4 reactions (excluding 'Message Links').
@@ -1229,6 +1244,54 @@ def test_create_link_buttons(
12291244 assert link_w ._wrapped_widget .attr_map == expected_attr_map
12301245 assert link_width == expected_link_width
12311246
1247+ @pytest .mark .parametrize (
1248+ [
1249+ "initial_code_snippet" ,
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+ ids = ["with_code_snippet" ],
1279+ )
1280+ def test_create_code_snippet_buttons (
1281+ self ,
1282+ initial_code_snippet : List [Tuple [str , List [Tuple [str , str ]]]],
1283+ expected_code : str ,
1284+ expected_attr_map : Dict [None , str ],
1285+ expected_focus_map : Dict [None , str ],
1286+ ) -> None :
1287+ [code_w ], _ = self .msg_info_view .create_code_snippet_buttons (
1288+ self .controller , initial_code_snippet
1289+ )
1290+
1291+ assert code_w ._wrapped_widget .original_widget .text == expected_code
1292+ assert code_w ._wrapped_widget .focus_map == expected_focus_map
1293+ assert code_w ._wrapped_widget .attr_map == expected_attr_map
1294+
12321295
12331296class TestStreamInfoView :
12341297 @pytest .fixture (autouse = True )
0 commit comments