@@ -757,3 +757,50 @@ def test_image_show_human_readable(self):
757757
758758 size_index = columns .index ('size' )
759759 self .assertEqual (data [size_index ].human_readable (), '2K' )
760+
761+
762+ class TestImageSave (image_fakes .TestImagev1 ):
763+ image = image_fakes .create_one_image ({})
764+
765+ def setUp (self ):
766+ super ().setUp ()
767+
768+ self .image_client .find_image .return_value = self .image
769+ self .image_client .download_image .return_value = self .image
770+
771+ # Get the command object to test
772+ self .cmd = image .SaveImage (self .app , None )
773+
774+ def test_save_data (self ):
775+ arglist = ['--file' , '/path/to/file' , self .image .id ]
776+
777+ verifylist = [('file' , '/path/to/file' ), ('image' , self .image .id )]
778+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
779+
780+ self .cmd .take_action (parsed_args )
781+
782+ self .image_client .download_image .assert_called_once_with (
783+ self .image .id , output = '/path/to/file' , stream = True , chunk_size = 1024
784+ )
785+
786+ def test_save_data_with_chunk_size (self ):
787+ arglist = [
788+ '--file' ,
789+ '/path/to/file' ,
790+ '--chunk-size' ,
791+ '2048' ,
792+ self .image .id ,
793+ ]
794+
795+ verifylist = [
796+ ('file' , '/path/to/file' ),
797+ ('chunk_size' , 2048 ),
798+ ('image' , self .image .id ),
799+ ]
800+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
801+
802+ self .cmd .take_action (parsed_args )
803+
804+ self .image_client .download_image .assert_called_once_with (
805+ self .image .id , output = '/path/to/file' , stream = True , chunk_size = 2048
806+ )
0 commit comments