@@ -278,10 +278,34 @@ class CustomDoc(BaseDoc):
278278 'Example here'
279279 ]
280280 assert (
281- new_custom_doc_model .schema ().get ('properties' )['a' ]['another_extra' ]
282- == 'I am another extra'
281+ new_custom_doc_model .schema ().get ('properties' )['a' ]['another_extra' ]
282+ == 'I am another extra'
283283 )
284284 assert (
285- new_custom_doc_model .schema ().get ('description' )
286- == 'Here I have the description of the class'
285+ new_custom_doc_model .schema ().get ('description' )
286+ == 'Here I have the description of the class'
287287 )
288+
289+
290+ def test_dynamic_class_creation_multiple_doclist_nested ():
291+ from docarray import BaseDoc , DocList
292+
293+ class MyTextDoc (BaseDoc ):
294+ text : str
295+
296+ class QuoteFile (BaseDoc ):
297+ texts : DocList [MyTextDoc ]
298+
299+ class SearchResult (BaseDoc ):
300+ results : DocList [QuoteFile ] = None
301+
302+ textlist = DocList [MyTextDoc ]([MyTextDoc (text = 'hey' )])
303+ models_created_by_name = {}
304+ SearchResult_aux = create_pure_python_type_model (SearchResult )
305+ _ = create_base_doc_from_schema (SearchResult_aux .schema (), 'SearchResult' ,
306+ models_created_by_name )
307+ QuoteFile_reconstructed_in_gateway_from_Search_results = models_created_by_name ['QuoteFile' ]
308+
309+ reconstructed_in_gateway_from_Search_results = QuoteFile_reconstructed_in_gateway_from_Search_results (
310+ texts = textlist )
311+ assert reconstructed_in_gateway_from_Search_results .texts [0 ].text == 'hey'
0 commit comments