@@ -21,10 +21,10 @@ def test_merge_basic_attributes_same_type(
21
21
model_property_factory ,
22
22
):
23
23
basic_props = [
24
- boolean_property_factory (default = True ),
25
- int_property_factory (default = 1 ),
26
- float_property_factory (default = 1.5 ),
27
- string_property_factory (default = "x" ),
24
+ boolean_property_factory (default = " True" ),
25
+ int_property_factory (default = "1" ),
26
+ float_property_factory (default = " 1.5" ),
27
+ string_property_factory (default = StringProperty . convert_value ( "x" ) ),
28
28
list_property_factory (),
29
29
model_property_factory (),
30
30
]
@@ -68,17 +68,17 @@ def test_incompatible_types(
68
68
69
69
def test_merge_int_with_float (int_property_factory , float_property_factory ):
70
70
int_prop = int_property_factory (description = "desc1" )
71
- float_prop = float_property_factory (default = 2 , description = "desc2" )
71
+ float_prop = float_property_factory (default = "2" , description = "desc2" )
72
72
73
73
assert merge_properties (int_prop , float_prop ) == (
74
74
evolve (int_prop , default = float_prop .default , description = float_prop .description )
75
75
)
76
76
assert merge_properties (float_prop , int_prop ) == (evolve (int_prop , default = float_prop .default ))
77
77
78
- float_prop_with_non_int_default = evolve (float_prop , default = 2.5 )
78
+ float_prop_with_non_int_default = evolve (float_prop , default = " 2.5" )
79
79
error = merge_properties (int_prop , float_prop_with_non_int_default )
80
80
assert isinstance (error , PropertyError ), "Expected invalid default to error"
81
- assert "default value" in error . detail
81
+ assert error . detail == "Invalid int value: 2.5"
82
82
83
83
84
84
def test_merge_with_any (
@@ -91,17 +91,16 @@ def test_merge_with_any(
91
91
):
92
92
original_desc = "description"
93
93
props = [
94
- boolean_property_factory (default = True , description = original_desc ),
95
- int_property_factory (default = 1 , description = original_desc ),
96
- float_property_factory (default = 1.5 , description = original_desc ),
97
- string_property_factory (default = "x" , description = original_desc ),
94
+ boolean_property_factory (default = " True" , description = original_desc ),
95
+ int_property_factory (default = "1" , description = original_desc ),
96
+ float_property_factory (default = " 1.5" , description = original_desc ),
97
+ string_property_factory (default = StringProperty . convert_value ( "x" ) , description = original_desc ),
98
98
model_property_factory (description = original_desc ),
99
99
]
100
100
any_prop = any_property_factory ()
101
101
for prop in props :
102
- expected_result = evolve (prop , description = original_desc , default = prop .default )
103
- assert merge_properties (any_prop , prop ) == expected_result
104
- assert merge_properties (prop , any_prop ) == expected_result
102
+ assert merge_properties (any_prop , prop ) == prop
103
+ assert merge_properties (prop , any_prop ) == prop
105
104
106
105
107
106
def test_merge_enums (enum_property_factory , config ):
@@ -134,9 +133,9 @@ def test_merge_enums(enum_property_factory, config):
134
133
135
134
def test_merge_string_with_string_enum (string_property_factory , enum_property_factory ):
136
135
values = {"A" : "A" , "B" : "B" }
137
- string_prop = string_property_factory (default = "default1 " , description = "desc1" , example = "example1" )
136
+ string_prop = string_property_factory (default = "A " , description = "desc1" , example = "example1" )
138
137
enum_prop = enum_property_factory (
139
- default = "default2 " ,
138
+ default = "test.B " ,
140
139
description = "desc2" ,
141
140
example = "example2" ,
142
141
values = values ,
@@ -147,17 +146,17 @@ def test_merge_string_with_string_enum(string_property_factory, enum_property_fa
147
146
assert merge_properties (enum_prop , string_prop ) == evolve (
148
147
enum_prop ,
149
148
required = True ,
150
- default = string_prop . default ,
149
+ default = "test.A" ,
151
150
description = string_prop .description ,
152
151
example = string_prop .example ,
153
152
)
154
153
155
154
156
155
def test_merge_int_with_int_enum (int_property_factory , enum_property_factory ):
157
156
values = {"VALUE_1" : 1 , "VALUE_2" : 2 }
158
- int_prop = int_property_factory (default = 100 , description = "desc1" , example = "example1" )
157
+ int_prop = int_property_factory (default = 1 , description = "desc1" , example = "example1" )
159
158
enum_prop = enum_property_factory (
160
- default = 200 ,
159
+ default = "test.VALUE_1" ,
161
160
description = "desc2" ,
162
161
example = "example2" ,
163
162
values = values ,
@@ -166,7 +165,7 @@ def test_merge_int_with_int_enum(int_property_factory, enum_property_factory):
166
165
167
166
assert merge_properties (int_prop , enum_prop ) == evolve (enum_prop , required = True )
168
167
assert merge_properties (enum_prop , int_prop ) == evolve (
169
- enum_prop , required = True , default = int_prop . default , description = int_prop .description , example = int_prop .example
168
+ enum_prop , required = True , description = int_prop .description , example = int_prop .example
170
169
)
171
170
172
171
0 commit comments