1515from unittest import mock
1616from unittest .mock import call
1717
18+ from cinderclient import api_versions
1819from osc_lib .cli import format_columns
1920from osc_lib import exceptions
2021from osc_lib import utils
@@ -327,7 +328,9 @@ def test_type_list_without_options(self):
327328 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
328329
329330 columns , data = self .cmd .take_action (parsed_args )
330- self .volume_types_mock .list .assert_called_once_with (is_public = None )
331+ self .volume_types_mock .list .assert_called_once_with (
332+ search_opts = {}, is_public = None
333+ )
331334 self .assertEqual (self .columns , columns )
332335 self .assertCountEqual (self .data , list (data ))
333336
@@ -344,7 +347,9 @@ def test_type_list_with_options(self):
344347 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
345348
346349 columns , data = self .cmd .take_action (parsed_args )
347- self .volume_types_mock .list .assert_called_once_with (is_public = True )
350+ self .volume_types_mock .list .assert_called_once_with (
351+ search_opts = {}, is_public = True
352+ )
348353 self .assertEqual (self .columns_long , columns )
349354 self .assertCountEqual (self .data_long , list (data ))
350355
@@ -360,7 +365,9 @@ def test_type_list_with_private_option(self):
360365 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
361366
362367 columns , data = self .cmd .take_action (parsed_args )
363- self .volume_types_mock .list .assert_called_once_with (is_public = False )
368+ self .volume_types_mock .list .assert_called_once_with (
369+ search_opts = {}, is_public = False
370+ )
364371 self .assertEqual (self .columns , columns )
365372 self .assertCountEqual (self .data , list (data ))
366373
@@ -381,6 +388,60 @@ def test_type_list_with_default_option(self):
381388 self .assertEqual (self .columns , columns )
382389 self .assertCountEqual (self .data_with_default_type , list (data ))
383390
391+ def test_type_list_with_property_option (self ):
392+ self .app .client_manager .volume .api_version = api_versions .APIVersion (
393+ '3.52'
394+ )
395+
396+ arglist = [
397+ "--property" ,
398+ "multiattach=<is> True" ,
399+ ]
400+ verifylist = [
401+ ("encryption_type" , False ),
402+ ("long" , False ),
403+ ("is_public" , None ),
404+ ("default" , False ),
405+ ("properties" , {"multiattach" : "<is> True" }),
406+ ]
407+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
408+
409+ columns , data = self .cmd .take_action (parsed_args )
410+ self .volume_types_mock .list .assert_called_once_with (
411+ search_opts = {"extra_specs" : {"multiattach" : "<is> True" }},
412+ is_public = None ,
413+ )
414+ self .assertEqual (self .columns , columns )
415+ self .assertCountEqual (self .data , list (data ))
416+
417+ def test_type_list_with_property_option_pre_v352 (self ):
418+ self .app .client_manager .volume .api_version = api_versions .APIVersion (
419+ '3.51'
420+ )
421+
422+ arglist = [
423+ "--property" ,
424+ "multiattach=<is> True" ,
425+ ]
426+ verifylist = [
427+ ("encryption_type" , False ),
428+ ("long" , False ),
429+ ("is_public" , None ),
430+ ("default" , False ),
431+ ("properties" , {"multiattach" : "<is> True" }),
432+ ]
433+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
434+
435+ exc = self .assertRaises (
436+ exceptions .CommandError ,
437+ self .cmd .take_action ,
438+ parsed_args ,
439+ )
440+ self .assertIn (
441+ '--os-volume-api-version 3.52 or greater is required' ,
442+ str (exc ),
443+ )
444+
384445 def test_type_list_with_encryption (self ):
385446 encryption_type = volume_fakes .create_one_encryption_volume_type (
386447 attrs = {'volume_type_id' : self .volume_types [0 ].id },
@@ -426,7 +487,9 @@ def test_type_list_with_encryption(self):
426487
427488 columns , data = self .cmd .take_action (parsed_args )
428489 self .volume_encryption_types_mock .list .assert_called_once_with ()
429- self .volume_types_mock .list .assert_called_once_with (is_public = None )
490+ self .volume_types_mock .list .assert_called_once_with (
491+ search_opts = {}, is_public = None
492+ )
430493 self .assertEqual (encryption_columns , columns )
431494 self .assertCountEqual (encryption_data , list (data ))
432495
@@ -459,7 +522,7 @@ def test_type_set(self):
459522 verifylist = [
460523 ('name' , 'new_name' ),
461524 ('description' , 'new_description' ),
462- ('property ' , None ),
525+ ('properties ' , None ),
463526 ('volume_type' , self .volume_type .id ),
464527 ]
465528 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
@@ -489,7 +552,7 @@ def test_type_set_property(self):
489552 verifylist = [
490553 ('name' , None ),
491554 ('description' , None ),
492- ('property ' , {'myprop' : 'myvalue' }),
555+ ('properties ' , {'myprop' : 'myvalue' }),
493556 ('volume_type' , self .volume_type .id ),
494557 ]
495558 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
@@ -857,7 +920,7 @@ def test_type_unset(self):
857920 self .volume_type .id ,
858921 ]
859922 verifylist = [
860- ('property ' , ['property' , 'multi_property' ]),
923+ ('properties ' , ['property' , 'multi_property' ]),
861924 ('volume_type' , self .volume_type .id ),
862925 ]
863926
0 commit comments