@@ -293,6 +293,46 @@ def test_get_type_string(self, mocker, nullable, required, no_optional, json, ex
293
293
)
294
294
assert p .get_type_string (no_optional = no_optional , json = json ) == expected
295
295
296
+ def test_get_base_type_string (self , mocker ):
297
+ from openapi_python_client .parser .properties import UnionProperty
298
+
299
+ inner_property_1 = mocker .MagicMock ()
300
+ inner_property_1 .get_type_string .side_effect = (
301
+ lambda no_optional = False , json = False : "inner_json_type_string_1" if json else "inner_type_string_1"
302
+ )
303
+ inner_property_2 = mocker .MagicMock ()
304
+ inner_property_2 .get_type_string .side_effect = (
305
+ lambda no_optional = False , json = False : "inner_json_type_string_2" if json else "inner_type_string_2"
306
+ )
307
+ p = UnionProperty (
308
+ name = "test" ,
309
+ required = False ,
310
+ default = None ,
311
+ inner_properties = [inner_property_1 , inner_property_2 ],
312
+ nullable = True ,
313
+ )
314
+ assert p .get_base_type_string () == "Union[inner_type_string_1, inner_type_string_2]"
315
+
316
+ def test_get_base_json_type_string (self , mocker ):
317
+ from openapi_python_client .parser .properties import UnionProperty
318
+
319
+ inner_property_1 = mocker .MagicMock ()
320
+ inner_property_1 .get_type_string .side_effect = (
321
+ lambda no_optional = False , json = False : "inner_json_type_string_1" if json else "inner_type_string_1"
322
+ )
323
+ inner_property_2 = mocker .MagicMock ()
324
+ inner_property_2 .get_type_string .side_effect = (
325
+ lambda no_optional = False , json = False : "inner_json_type_string_2" if json else "inner_type_string_2"
326
+ )
327
+ p = UnionProperty (
328
+ name = "test" ,
329
+ required = False ,
330
+ default = None ,
331
+ inner_properties = [inner_property_1 , inner_property_2 ],
332
+ nullable = True ,
333
+ )
334
+ assert p .get_base_json_type_string () == "Union[inner_json_type_string_1, inner_json_type_string_2]"
335
+
296
336
def test_get_imports (self , mocker ):
297
337
from openapi_python_client .parser .properties import UnionProperty
298
338
0 commit comments