@@ -37,6 +37,17 @@ def test_aaz_model_and_simple_types(self):
3737
3838 with self .assertRaises (AAZInvalidValueError ):
3939 v .properties .count = "a"
40+
41+ with self .assertRaises (AAZInvalidValueError ):
42+ v .properties .count = "1a"
43+
44+ with self .assertRaises (AAZInvalidValueError ):
45+ v .properties .count = "1.1"
46+
47+ # support string input with json parsing
48+ v .properties .count = "12"
49+ assert v .properties .count == 12
50+ assert v .properties .count ._data == 12
4051
4152 # test string type
4253 model_schema .properties .name = AAZStrType ()
@@ -70,6 +81,17 @@ def test_aaz_model_and_simple_types(self):
7081 assert not v .properties .enable
7182 assert v .properties .enable is not False
7283
84+ with self .assertRaises (AAZInvalidValueError ):
85+ v .properties .enable = 1
86+
87+ # support string input with json parsing
88+ v .properties .enable = "false"
89+ v .properties .enable = "true"
90+ assert v .properties .enable == True
91+ assert not (v .properties .enable != True )
92+ assert v .properties .enable
93+ assert v .properties .enable is not True # cannot us is
94+
7395 # test float type
7496 model_schema .properties .height = AAZFloatType ()
7597 v .properties .height = 10.0
@@ -86,6 +108,17 @@ def test_aaz_model_and_simple_types(self):
86108 v .properties .height = 10 # test assign int
87109 assert str (v .properties .height ) == "10.0"
88110
111+ with self .assertRaises (AAZInvalidValueError ):
112+ v .properties .height = "1a"
113+
114+ v .properties .height = "12.1"
115+ assert v .properties .height == 12.1
116+ assert v .properties .height ._data == 12.1
117+
118+ v .properties .height = "12"
119+ assert v .properties .height == 12
120+ assert v .properties .height ._data == 12
121+
89122 # test assign properties by dict
90123 v .properties = {
91124 "count" : 100 ,
@@ -100,6 +133,21 @@ def test_aaz_model_and_simple_types(self):
100133 assert v .properties .enable ._data == True
101134 assert v .properties .height ._data == 111
102135
136+ # test assign properties by dict with all string value
137+ v .properties = {
138+ "count" : "101" ,
139+ "name" : "abcd" ,
140+ "enable" : "False" ,
141+ "height" : "121"
142+ }
143+
144+ assert not v .properties ._is_patch
145+ assert v .properties .name ._data == "abcd"
146+ assert v .properties .count ._data == 101
147+ assert v .properties .enable ._data == False
148+ assert v .properties .height ._data == 121
149+
150+
103151 def test_aaz_dict_type (self ):
104152 from azure .cli .core .aaz ._field_type import AAZObjectType , AAZDictType , AAZStrType
105153 from azure .cli .core .aaz ._field_value import AAZObject
0 commit comments