@@ -682,6 +682,74 @@ def test_volume_create_with_multi_source(self):
682682 verifylist ,
683683 )
684684
685+ def test_volume_create_hints (self ):
686+ """--hint needs to behave differently based on the given hint
687+
688+ different_host and same_host need to append to a list if given multiple
689+ times. All other parameter are strings.
690+ """
691+ arglist = [
692+ '--size' ,
693+ str (self .new_volume .size ),
694+ '--hint' ,
695+ 'k=v' ,
696+ '--hint' ,
697+ 'k=v2' ,
698+ '--hint' ,
699+ 'same_host=v3' ,
700+ '--hint' ,
701+ 'same_host=v4' ,
702+ '--hint' ,
703+ 'different_host=v5' ,
704+ '--hint' ,
705+ 'local_to_instance=v6' ,
706+ '--hint' ,
707+ 'different_host=v7' ,
708+ self .new_volume .name ,
709+ ]
710+ verifylist = [
711+ ('size' , self .new_volume .size ),
712+ (
713+ 'hint' ,
714+ {
715+ 'k' : 'v2' ,
716+ 'same_host' : ['v3' , 'v4' ],
717+ 'local_to_instance' : 'v6' ,
718+ 'different_host' : ['v5' , 'v7' ],
719+ },
720+ ),
721+ ('name' , self .new_volume .name ),
722+ ]
723+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
724+
725+ # In base command class ShowOne in cliff, abstract method take_action()
726+ # returns a two-part tuple with a tuple of column names and a tuple of
727+ # data to be shown.
728+ columns , data = self .cmd .take_action (parsed_args )
729+
730+ self .volumes_mock .create .assert_called_with (
731+ size = self .new_volume .size ,
732+ snapshot_id = None ,
733+ name = self .new_volume .name ,
734+ description = None ,
735+ volume_type = None ,
736+ availability_zone = None ,
737+ metadata = None ,
738+ imageRef = None ,
739+ source_volid = None ,
740+ consistencygroup_id = None ,
741+ scheduler_hints = {
742+ 'k' : 'v2' ,
743+ 'same_host' : ['v3' , 'v4' ],
744+ 'local_to_instance' : 'v6' ,
745+ 'different_host' : ['v5' , 'v7' ],
746+ },
747+ backup_id = None ,
748+ )
749+
750+ self .assertEqual (self .columns , columns )
751+ self .assertCountEqual (self .datalist , data )
752+
685753
686754class TestVolumeDelete (TestVolume ):
687755 def setUp (self ):
0 commit comments