@@ -46,18 +46,19 @@ def setUp(self):
4646
4747
4848class TestTypeCreate (TestType ):
49- project = identity_fakes .FakeProject .create_one_project ()
50- columns = (
51- 'description' ,
52- 'id' ,
53- 'is_public' ,
54- 'name' ,
55- )
56-
5749 def setUp (self ):
5850 super ().setUp ()
5951
60- self .new_volume_type = volume_fakes .create_one_volume_type ()
52+ self .new_volume_type = volume_fakes .create_one_volume_type (
53+ methods = {'set_keys' : None },
54+ )
55+ self .project = identity_fakes .FakeProject .create_one_project ()
56+ self .columns = (
57+ 'description' ,
58+ 'id' ,
59+ 'is_public' ,
60+ 'name' ,
61+ )
6162 self .data = (
6263 self .new_volume_type .description ,
6364 self .new_volume_type .id ,
@@ -121,7 +122,45 @@ def test_type_create_private(self):
121122 self .assertEqual (self .columns , columns )
122123 self .assertCountEqual (self .data , data )
123124
124- def test_public_type_create_with_project (self ):
125+ def test_type_create_with_properties (self ):
126+ arglist = [
127+ '--property' ,
128+ 'myprop=myvalue' ,
129+ # this combination isn't viable server-side but is okay for testing
130+ '--multiattach' ,
131+ '--cacheable' ,
132+ '--replicated' ,
133+ self .new_volume_type .name ,
134+ ]
135+ verifylist = [
136+ ('properties' , {'myprop' : 'myvalue' }),
137+ ('multiattach' , True ),
138+ ('cacheable' , True ),
139+ ('replicated' , True ),
140+ ('name' , self .new_volume_type .name ),
141+ ]
142+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
143+
144+ columns , data = self .cmd .take_action (parsed_args )
145+ self .volume_types_mock .create .assert_called_with (
146+ self .new_volume_type .name , description = None
147+ )
148+ self .new_volume_type .set_keys .assert_called_once_with (
149+ {
150+ 'myprop' : 'myvalue' ,
151+ 'multiattach' : '<is> True' ,
152+ 'cacheable' : '<is> True' ,
153+ 'replication_enabled' : '<is> True' ,
154+ }
155+ )
156+
157+ self .columns += ('properties' ,)
158+ self .data += (format_columns .DictColumn (None ),)
159+
160+ self .assertEqual (self .columns , columns )
161+ self .assertCountEqual (self .data , data )
162+
163+ def test_public_type_create_with_project_public (self ):
125164 arglist = [
126165 '--project' ,
127166 self .project .id ,
@@ -134,7 +173,9 @@ def test_public_type_create_with_project(self):
134173 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
135174
136175 self .assertRaises (
137- exceptions .CommandError , self .cmd .take_action , parsed_args
176+ exceptions .CommandError ,
177+ self .cmd .take_action ,
178+ parsed_args ,
138179 )
139180
140181 def test_type_create_with_encryption (self ):
@@ -388,47 +429,60 @@ def test_type_list_with_default_option(self):
388429 self .assertEqual (self .columns , columns )
389430 self .assertCountEqual (self .data_with_default_type , list (data ))
390431
391- def test_type_list_with_property_option (self ):
432+ def test_type_list_with_properties (self ):
392433 self .app .client_manager .volume .api_version = api_versions .APIVersion (
393434 '3.52'
394435 )
395436
396437 arglist = [
397438 "--property" ,
398- "multiattach=<is> True" ,
439+ "foo=bar" ,
440+ "--multiattach" ,
441+ "--cacheable" ,
442+ "--replicated" ,
399443 ]
400444 verifylist = [
401445 ("encryption_type" , False ),
402446 ("long" , False ),
403447 ("is_public" , None ),
404448 ("default" , False ),
405- ("properties" , {"multiattach" : "<is> True" }),
449+ ("properties" , {"foo" : "bar" }),
450+ ("multiattach" , True ),
451+ ("cacheable" , True ),
452+ ("replicated" , True ),
406453 ]
407454 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
408455
409456 columns , data = self .cmd .take_action (parsed_args )
410457 self .volume_types_mock .list .assert_called_once_with (
411- search_opts = {"extra_specs" : {"multiattach" : "<is> True" }},
458+ search_opts = {
459+ "extra_specs" : {
460+ "foo" : "bar" ,
461+ "multiattach" : "<is> True" ,
462+ "cacheable" : "<is> True" ,
463+ "replication_enabled" : "<is> True" ,
464+ }
465+ },
412466 is_public = None ,
413467 )
414468 self .assertEqual (self .columns , columns )
415469 self .assertCountEqual (self .data , list (data ))
416470
417- def test_type_list_with_property_option_pre_v352 (self ):
471+ def test_type_list_with_properties_pre_v352 (self ):
418472 self .app .client_manager .volume .api_version = api_versions .APIVersion (
419473 '3.51'
420474 )
421475
422476 arglist = [
423477 "--property" ,
424- "multiattach=<is> True " ,
478+ "foo=bar " ,
425479 ]
426480 verifylist = [
427481 ("encryption_type" , False ),
428482 ("long" , False ),
429483 ("is_public" , None ),
430484 ("default" , False ),
431- ("properties" , {"multiattach " : "<is> True " }),
485+ ("properties" , {"foo " : "bar " }),
432486 ]
433487 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
434488
@@ -547,12 +601,19 @@ def test_type_set_property(self):
547601 arglist = [
548602 '--property' ,
549603 'myprop=myvalue' ,
604+ # this combination isn't viable server-side but is okay for testing
605+ '--multiattach' ,
606+ '--cacheable' ,
607+ '--replicated' ,
550608 self .volume_type .id ,
551609 ]
552610 verifylist = [
553611 ('name' , None ),
554612 ('description' , None ),
555613 ('properties' , {'myprop' : 'myvalue' }),
614+ ('multiattach' , True ),
615+ ('cacheable' , True ),
616+ ('replicated' , True ),
556617 ('volume_type' , self .volume_type .id ),
557618 ]
558619 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
@@ -561,7 +622,12 @@ def test_type_set_property(self):
561622 self .assertIsNone (result )
562623
563624 self .volume_type .set_keys .assert_called_once_with (
564- {'myprop' : 'myvalue' }
625+ {
626+ 'myprop' : 'myvalue' ,
627+ 'multiattach' : '<is> True' ,
628+ 'cacheable' : '<is> True' ,
629+ 'replication_enabled' : '<is> True' ,
630+ }
565631 )
566632 self .volume_type_access_mock .add_project_access .assert_not_called ()
567633 self .volume_encryption_types_mock .update .assert_not_called ()
0 commit comments