@@ -48,18 +48,19 @@ def setUp(self):
4848
4949
5050class TestTypeCreate (TestType ):
51- project = identity_fakes .FakeProject .create_one_project ()
52- columns = (
53- 'description' ,
54- 'id' ,
55- 'is_public' ,
56- 'name' ,
57- )
58-
5951 def setUp (self ):
6052 super ().setUp ()
6153
62- self .new_volume_type = volume_fakes .create_one_volume_type ()
54+ self .new_volume_type = volume_fakes .create_one_volume_type (
55+ methods = {'set_keys' : None },
56+ )
57+ self .project = identity_fakes .FakeProject .create_one_project ()
58+ self .columns = (
59+ 'description' ,
60+ 'id' ,
61+ 'is_public' ,
62+ 'name' ,
63+ )
6364 self .data = (
6465 self .new_volume_type .description ,
6566 self .new_volume_type .id ,
@@ -123,7 +124,45 @@ def test_type_create_private(self):
123124 self .assertEqual (self .columns , columns )
124125 self .assertCountEqual (self .data , data )
125126
126- def test_public_type_create_with_project (self ):
127+ def test_type_create_with_properties (self ):
128+ arglist = [
129+ '--property' ,
130+ 'myprop=myvalue' ,
131+ # this combination isn't viable server-side but is okay for testing
132+ '--multiattach' ,
133+ '--cacheable' ,
134+ '--replicated' ,
135+ self .new_volume_type .name ,
136+ ]
137+ verifylist = [
138+ ('properties' , {'myprop' : 'myvalue' }),
139+ ('multiattach' , True ),
140+ ('cacheable' , True ),
141+ ('replicated' , True ),
142+ ('name' , self .new_volume_type .name ),
143+ ]
144+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
145+
146+ columns , data = self .cmd .take_action (parsed_args )
147+ self .volume_types_mock .create .assert_called_with (
148+ self .new_volume_type .name , description = None
149+ )
150+ self .new_volume_type .set_keys .assert_called_once_with (
151+ {
152+ 'myprop' : 'myvalue' ,
153+ 'multiattach' : '<is> True' ,
154+ 'cacheable' : '<is> True' ,
155+ 'replication_enabled' : '<is> True' ,
156+ }
157+ )
158+
159+ self .columns += ('properties' ,)
160+ self .data += (format_columns .DictColumn (None ),)
161+
162+ self .assertEqual (self .columns , columns )
163+ self .assertCountEqual (self .data , data )
164+
165+ def test_public_type_create_with_project_public (self ):
127166 arglist = [
128167 '--project' ,
129168 self .project .id ,
@@ -136,7 +175,9 @@ def test_public_type_create_with_project(self):
136175 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
137176
138177 self .assertRaises (
139- exceptions .CommandError , self .cmd .take_action , parsed_args
178+ exceptions .CommandError ,
179+ self .cmd .take_action ,
180+ parsed_args ,
140181 )
141182
142183 def test_type_create_with_encryption (self ):
@@ -390,47 +431,60 @@ def test_type_list_with_default_option(self):
390431 self .assertEqual (self .columns , columns )
391432 self .assertCountEqual (self .data_with_default_type , list (data ))
392433
393- def test_type_list_with_property_option (self ):
434+ def test_type_list_with_properties (self ):
394435 self .app .client_manager .volume .api_version = api_versions .APIVersion (
395436 '3.52'
396437 )
397438
398439 arglist = [
399440 "--property" ,
400- "multiattach=<is> True" ,
441+ "foo=bar" ,
442+ "--multiattach" ,
443+ "--cacheable" ,
444+ "--replicated" ,
401445 ]
402446 verifylist = [
403447 ("encryption_type" , False ),
404448 ("long" , False ),
405449 ("is_public" , None ),
406450 ("default" , False ),
407- ("properties" , {"multiattach" : "<is> True" }),
451+ ("properties" , {"foo" : "bar" }),
452+ ("multiattach" , True ),
453+ ("cacheable" , True ),
454+ ("replicated" , True ),
408455 ]
409456 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
410457
411458 columns , data = self .cmd .take_action (parsed_args )
412459 self .volume_types_mock .list .assert_called_once_with (
413- search_opts = {"extra_specs" : {"multiattach" : "<is> True" }},
460+ search_opts = {
461+ "extra_specs" : {
462+ "foo" : "bar" ,
463+ "multiattach" : "<is> True" ,
464+ "cacheable" : "<is> True" ,
465+ "replication_enabled" : "<is> True" ,
466+ }
467+ },
414468 is_public = None ,
415469 )
416470 self .assertEqual (self .columns , columns )
417471 self .assertCountEqual (self .data , list (data ))
418472
419- def test_type_list_with_property_option_pre_v352 (self ):
473+ def test_type_list_with_properties_pre_v352 (self ):
420474 self .app .client_manager .volume .api_version = api_versions .APIVersion (
421475 '3.51'
422476 )
423477
424478 arglist = [
425479 "--property" ,
426- "multiattach=<is> True " ,
480+ "foo=bar " ,
427481 ]
428482 verifylist = [
429483 ("encryption_type" , False ),
430484 ("long" , False ),
431485 ("is_public" , None ),
432486 ("default" , False ),
433- ("properties" , {"multiattach " : "<is> True " }),
487+ ("properties" , {"foo " : "bar " }),
434488 ]
435489 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
436490
@@ -549,12 +603,19 @@ def test_type_set_property(self):
549603 arglist = [
550604 '--property' ,
551605 'myprop=myvalue' ,
606+ # this combination isn't viable server-side but is okay for testing
607+ '--multiattach' ,
608+ '--cacheable' ,
609+ '--replicated' ,
552610 self .volume_type .id ,
553611 ]
554612 verifylist = [
555613 ('name' , None ),
556614 ('description' , None ),
557615 ('properties' , {'myprop' : 'myvalue' }),
616+ ('multiattach' , True ),
617+ ('cacheable' , True ),
618+ ('replicated' , True ),
558619 ('volume_type' , self .volume_type .id ),
559620 ]
560621 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
@@ -563,7 +624,12 @@ def test_type_set_property(self):
563624 self .assertIsNone (result )
564625
565626 self .volume_type .set_keys .assert_called_once_with (
566- {'myprop' : 'myvalue' }
627+ {
628+ 'myprop' : 'myvalue' ,
629+ 'multiattach' : '<is> True' ,
630+ 'cacheable' : '<is> True' ,
631+ 'replication_enabled' : '<is> True' ,
632+ }
567633 )
568634 self .volume_type_access_mock .add_project_access .assert_not_called ()
569635 self .volume_encryption_types_mock .update .assert_not_called ()
0 commit comments