@@ -670,6 +670,11 @@ def setUp(self):
670670
671671 def test_server_add_volume (self ):
672672 servers = self .setup_servers_mock (count = 1 )
673+ volume_attachment = \
674+ compute_fakes .FakeVolumeAttachment .create_one_volume_attachment ()
675+ self .servers_volumes_mock .create_server_volume .return_value = \
676+ volume_attachment
677+
673678 arglist = [
674679 '--device' , '/dev/sdb' ,
675680 servers [0 ].id ,
@@ -683,18 +688,32 @@ def test_server_add_volume(self):
683688
684689 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
685690
686- result = self .cmd .take_action (parsed_args )
691+ expected_columns = ('ID' , 'Server ID' , 'Volume ID' , 'Device' )
692+ expected_data = (
693+ volume_attachment .id ,
694+ volume_attachment .serverId ,
695+ volume_attachment .volumeId ,
696+ volume_attachment .device ,
697+ )
698+
699+ columns , data = self .cmd .take_action (parsed_args )
687700
688701 self .servers_volumes_mock .create_server_volume .assert_called_once_with (
689702 servers [0 ].id , self .volume .id , device = '/dev/sdb' )
690- self .assertIsNone (result )
703+ self .assertEqual (expected_columns , columns )
704+ self .assertEqual (expected_data , data )
691705
692706 def test_server_add_volume_with_tag (self ):
693707 # requires API 2.49 or later
694708 self .app .client_manager .compute .api_version = api_versions .APIVersion (
695709 '2.49' )
696710
697711 servers = self .setup_servers_mock (count = 1 )
712+ volume_attachment = \
713+ compute_fakes .FakeVolumeAttachment .create_one_volume_attachment ()
714+ self .servers_volumes_mock .create_server_volume .return_value = \
715+ volume_attachment
716+
698717 arglist = [
699718 '--device' , '/dev/sdb' ,
700719 '--tag' , 'foo' ,
@@ -710,11 +729,21 @@ def test_server_add_volume_with_tag(self):
710729
711730 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
712731
713- result = self .cmd .take_action (parsed_args )
732+ expected_columns = ('ID' , 'Server ID' , 'Volume ID' , 'Device' , 'Tag' )
733+ expected_data = (
734+ volume_attachment .id ,
735+ volume_attachment .serverId ,
736+ volume_attachment .volumeId ,
737+ volume_attachment .device ,
738+ volume_attachment .tag ,
739+ )
740+
741+ columns , data = self .cmd .take_action (parsed_args )
714742
715743 self .servers_volumes_mock .create_server_volume .assert_called_once_with (
716744 servers [0 ].id , self .volume .id , device = '/dev/sdb' , tag = 'foo' )
717- self .assertIsNone (result )
745+ self .assertEqual (expected_columns , columns )
746+ self .assertEqual (expected_data , data )
718747
719748 def test_server_add_volume_with_tag_pre_v249 (self ):
720749 self .app .client_manager .compute .api_version = api_versions .APIVersion (
@@ -746,6 +775,11 @@ def test_server_add_volume_with_enable_delete_on_termination(self):
746775 '2.79' )
747776
748777 servers = self .setup_servers_mock (count = 1 )
778+ volume_attachment = \
779+ compute_fakes .FakeVolumeAttachment .create_one_volume_attachment ()
780+ self .servers_volumes_mock .create_server_volume .return_value = \
781+ volume_attachment
782+
749783 arglist = [
750784 '--enable-delete-on-termination' ,
751785 '--device' , '/dev/sdb' ,
@@ -761,18 +795,41 @@ def test_server_add_volume_with_enable_delete_on_termination(self):
761795 ]
762796 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
763797
764- result = self .cmd .take_action (parsed_args )
798+ expected_columns = (
799+ 'ID' ,
800+ 'Server ID' ,
801+ 'Volume ID' ,
802+ 'Device' ,
803+ 'Tag' ,
804+ 'Delete On Termination' ,
805+ )
806+ expected_data = (
807+ volume_attachment .id ,
808+ volume_attachment .serverId ,
809+ volume_attachment .volumeId ,
810+ volume_attachment .device ,
811+ volume_attachment .tag ,
812+ volume_attachment .delete_on_termination ,
813+ )
814+
815+ columns , data = self .cmd .take_action (parsed_args )
765816
766817 self .servers_volumes_mock .create_server_volume .assert_called_once_with (
767818 servers [0 ].id , self .volume .id ,
768819 device = '/dev/sdb' , delete_on_termination = True )
769- self .assertIsNone (result )
820+ self .assertEqual (expected_columns , columns )
821+ self .assertEqual (expected_data , data )
770822
771823 def test_server_add_volume_with_disable_delete_on_termination (self ):
772824 self .app .client_manager .compute .api_version = api_versions .APIVersion (
773825 '2.79' )
774826
775827 servers = self .setup_servers_mock (count = 1 )
828+ volume_attachment = \
829+ compute_fakes .FakeVolumeAttachment .create_one_volume_attachment ()
830+ self .servers_volumes_mock .create_server_volume .return_value = \
831+ volume_attachment
832+
776833 arglist = [
777834 '--disable-delete-on-termination' ,
778835 '--device' , '/dev/sdb' ,
@@ -788,12 +845,30 @@ def test_server_add_volume_with_disable_delete_on_termination(self):
788845 ]
789846 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
790847
791- result = self .cmd .take_action (parsed_args )
848+ expected_columns = (
849+ 'ID' ,
850+ 'Server ID' ,
851+ 'Volume ID' ,
852+ 'Device' ,
853+ 'Tag' ,
854+ 'Delete On Termination' ,
855+ )
856+ expected_data = (
857+ volume_attachment .id ,
858+ volume_attachment .serverId ,
859+ volume_attachment .volumeId ,
860+ volume_attachment .device ,
861+ volume_attachment .tag ,
862+ volume_attachment .delete_on_termination ,
863+ )
864+
865+ columns , data = self .cmd .take_action (parsed_args )
792866
793867 self .servers_volumes_mock .create_server_volume .assert_called_once_with (
794868 servers [0 ].id , self .volume .id ,
795869 device = '/dev/sdb' , delete_on_termination = False )
796- self .assertIsNone (result )
870+ self .assertEqual (expected_columns , columns )
871+ self .assertEqual (expected_data , data )
797872
798873 def test_server_add_volume_with_enable_delete_on_termination_pre_v279 (
799874 self ,
0 commit comments