22
33import pytest
44
5- from json_to_models .dynamic_typing import (AbsoluteModelRef , DList , DOptional , IntString , ModelMeta , ModelPtr ,
6- compile_imports )
5+ from json_to_models .dynamic_typing import (AbsoluteModelRef , DDict , DList , DOptional , IntString , ModelMeta , ModelPtr ,
6+ Unknown , compile_imports )
77from json_to_models .models import indent , sort_fields
88from json_to_models .models .base import GenericModelCodeGenerator , generate_code
99
@@ -101,7 +101,8 @@ class Test:
101101 "model" : ("Test" , {
102102 "foo" : int ,
103103 "baz" : DOptional (DList (DList (str ))),
104- "bar" : IntString
104+ "bar" : IntString ,
105+ "d" : DDict (Unknown )
105106 }),
106107 "fields_data" : {
107108 "foo" : {
@@ -115,25 +116,31 @@ class Test:
115116 "bar" : {
116117 "name" : "bar" ,
117118 "type" : "IntString"
119+ },
120+ "d" : {
121+ "name" : "d" ,
122+ "type" : "Dict[str, Any]"
118123 }
119124 },
120125 "fields" : {
121126 "imports" : "from json_to_models.dynamic_typing import IntString\n "
122- "from typing import List, Optional" ,
127+ "from typing import Any, Dict, List, Optional" ,
123128 "fields" : [
124129 "foo: int" ,
125130 "bar: IntString" ,
131+ "d: Dict[str, Any]" ,
126132 "baz: Optional[List[List[str]]]" ,
127133 ]
128134 },
129135 "generated" : trim ("""
130136 from json_to_models.dynamic_typing import IntString
131- from typing import List, Optional
137+ from typing import Any, Dict, List, Optional
132138
133139
134140 class Test:
135141 foo: int
136142 bar: IntString
143+ d: Dict[str, Any]
137144 baz: Optional[List[List[str]]]
138145 """ )
139146 }
0 commit comments