@@ -1293,69 +1293,80 @@ def test_volume_list_backward_compatibility(self):
12931293 self .assertIn (self .mock_volume .name , each_volume )
12941294
12951295
1296- class TestVolumeMigrate (TestVolume ):
1297- _volume = volume_fakes .create_one_volume ()
1298-
1296+ class TestVolumeMigrate (volume_fakes .TestVolume ):
12991297 def setUp (self ):
13001298 super ().setUp ()
13011299
1302- self .volumes_mock .get .return_value = self ._volume
1303- self .volumes_mock .migrate_volume .return_value = None
1304- # Get the command object to test
1300+ self .volume = sdk_fakes .generate_fake_resource (_volume .Volume )
1301+ self .volume_sdk_client .find_volume .return_value = self .volume
1302+ self .volume_sdk_client .migrate_volume .return_value = None
1303+
13051304 self .cmd = volume .MigrateVolume (self .app , None )
13061305
13071306 def test_volume_migrate (self ):
13081307 arglist = [
13091308 "--host" ,
13101309 "host@backend-name#pool" ,
1311- self ._volume .id ,
1310+ self .volume .id ,
13121311 ]
13131312 verifylist = [
13141313 ("force_host_copy" , False ),
13151314 ("lock_volume" , False ),
13161315 ("host" , "host@backend-name#pool" ),
1317- ("volume" , self ._volume .id ),
1316+ ("volume" , self .volume .id ),
13181317 ]
13191318 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
13201319
13211320 result = self .cmd .take_action (parsed_args )
1322- self .volumes_mock .get .assert_called_once_with (self ._volume .id )
1323- self .volumes_mock .migrate_volume .assert_called_once_with (
1324- self ._volume .id , "host@backend-name#pool" , False , False
1325- )
13261321 self .assertIsNone (result )
13271322
1323+ self .volume_sdk_client .find_volume .assert_called_with (
1324+ self .volume .id , ignore_missing = False
1325+ )
1326+ self .volume_sdk_client .migrate_volume .assert_called_once_with (
1327+ self .volume .id ,
1328+ host = "host@backend-name#pool" ,
1329+ force_host_copy = False ,
1330+ lock_volume = False ,
1331+ )
1332+
13281333 def test_volume_migrate_with_option (self ):
13291334 arglist = [
13301335 "--force-host-copy" ,
13311336 "--lock-volume" ,
13321337 "--host" ,
13331338 "host@backend-name#pool" ,
1334- self ._volume .id ,
1339+ self .volume .id ,
13351340 ]
13361341 verifylist = [
13371342 ("force_host_copy" , True ),
13381343 ("lock_volume" , True ),
13391344 ("host" , "host@backend-name#pool" ),
1340- ("volume" , self ._volume .id ),
1345+ ("volume" , self .volume .id ),
13411346 ]
13421347 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
13431348
13441349 result = self .cmd .take_action (parsed_args )
1345- self .volumes_mock .get .assert_called_once_with (self ._volume .id )
1346- self .volumes_mock .migrate_volume .assert_called_once_with (
1347- self ._volume .id , "host@backend-name#pool" , True , True
1348- )
13491350 self .assertIsNone (result )
13501351
1352+ self .volume_sdk_client .find_volume .assert_called_with (
1353+ self .volume .id , ignore_missing = False
1354+ )
1355+ self .volume_sdk_client .migrate_volume .assert_called_once_with (
1356+ self .volume .id ,
1357+ host = "host@backend-name#pool" ,
1358+ force_host_copy = True ,
1359+ lock_volume = True ,
1360+ )
1361+
13511362 def test_volume_migrate_without_host (self ):
13521363 arglist = [
1353- self ._volume .id ,
1364+ self .volume .id ,
13541365 ]
13551366 verifylist = [
13561367 ("force_host_copy" , False ),
13571368 ("lock_volume" , False ),
1358- ("volume" , self ._volume .id ),
1369+ ("volume" , self .volume .id ),
13591370 ]
13601371
13611372 self .assertRaises (
@@ -1366,6 +1377,9 @@ def test_volume_migrate_without_host(self):
13661377 verifylist ,
13671378 )
13681379
1380+ self .volume_sdk_client .find_volume .assert_not_called ()
1381+ self .volume_sdk_client .migrate_volume .assert_not_called ()
1382+
13691383
13701384class TestVolumeSet (TestVolume ):
13711385 volume_type = volume_fakes .create_one_volume_type ()
0 commit comments