@@ -1083,3 +1083,38 @@ def test_complex(self):
10831083 ],
10841084 )
10851085 self .assertDictEqual (dict_block , class_block .to_dict ())
1086+
1087+ def test_elements_are_parsed (self ):
1088+ dict_block = {
1089+ "type" : "rich_text" ,
1090+ "elements" : [
1091+ {
1092+ "type" : "rich_text_section" ,
1093+ "elements" : [{"type" : "text" , "text" : "Hello there, I am a basic rich text block!" }],
1094+ },
1095+ {
1096+ "type" : "rich_text_quote" ,
1097+ "elements" : [{"type" : "text" , "text" : "this is very important" }],
1098+ },
1099+ {
1100+ "type" : "rich_text_preformatted" ,
1101+ "elements" : [{"type" : "text" , "text" : 'print("Hello world")' }],
1102+ },
1103+ {
1104+ "type" : "rich_text_list" ,
1105+ "elements" : [
1106+ {"type" : "rich_text_section" , "elements" : [{"type" : "text" , "text" : "a" }]},
1107+ ],
1108+ },
1109+ ],
1110+ }
1111+ block = RichTextBlock (** dict_block )
1112+ self .assertIsInstance (block .elements [0 ], RichTextSectionElement )
1113+ self .assertIsInstance (block .elements [0 ].elements [0 ], RichTextElementParts .Text )
1114+ self .assertIsInstance (block .elements [1 ], RichTextQuoteElement )
1115+ self .assertIsInstance (block .elements [1 ].elements [0 ], RichTextElementParts .Text )
1116+ self .assertIsInstance (block .elements [2 ], RichTextPreformattedElement )
1117+ self .assertIsInstance (block .elements [2 ].elements [0 ], RichTextElementParts .Text )
1118+ self .assertIsInstance (block .elements [3 ], RichTextListElement )
1119+ self .assertIsInstance (block .elements [3 ].elements [0 ], RichTextSectionElement )
1120+ self .assertIsInstance (block .elements [3 ].elements [0 ].elements [0 ], RichTextElementParts .Text )
0 commit comments