@@ -815,3 +815,46 @@ def test_billing(self):
815815 }
816816 self .assert_no_fail (result )
817817 self .assertEqual (json .loads (result .output ), vir_billing )
818+
819+ def test_vs_migrate_list (self ):
820+ result = self .run_command (['vs' , 'migrate' ])
821+ self .assert_no_fail (result )
822+ self .assert_called_with ('SoftLayer_Account' , 'getVirtualGuests' )
823+ self .assert_not_called_with ('SoftLayer_Virtual_Guest' , 'migrate' )
824+ self .assert_not_called_with ('SoftLayer_Virtual_Guest' , 'migrateDedicatedHost' )
825+
826+ def test_vs_migrate_guest (self ):
827+ result = self .run_command (['vs' , 'migrate' , '-g' , '100' ])
828+
829+ self .assert_no_fail (result )
830+ self .assertIn ('Started a migration on' , result .output )
831+ self .assert_not_called_with ('SoftLayer_Account' , 'getVirtualGuests' )
832+ self .assert_called_with ('SoftLayer_Virtual_Guest' , 'migrate' , identifier = 100 )
833+ self .assert_not_called_with ('SoftLayer_Virtual_Guest' , 'migrateDedicatedHost' )
834+
835+ def test_vs_migrate_all (self ):
836+ result = self .run_command (['vs' , 'migrate' , '-a' ])
837+ self .assert_no_fail (result )
838+ self .assertIn ('Started a migration on' , result .output )
839+ self .assert_called_with ('SoftLayer_Virtual_Guest' , 'migrate' , identifier = 100 )
840+ self .assert_called_with ('SoftLayer_Virtual_Guest' , 'migrate' , identifier = 104 )
841+ self .assert_not_called_with ('SoftLayer_Virtual_Guest' , 'migrateDedicatedHost' )
842+
843+ def test_vs_migrate_dedicated (self ):
844+ result = self .run_command (['vs' , 'migrate' , '-g' , '100' , '-h' , '999' ])
845+ self .assert_no_fail (result )
846+ self .assertIn ('Started a migration on' , result .output )
847+ self .assert_not_called_with ('SoftLayer_Account' , 'getVirtualGuests' )
848+ self .assert_not_called_with ('SoftLayer_Virtual_Guest' , 'migrate' , identifier = 100 )
849+ self .assert_not_called_with ('SoftLayer_Virtual_Guest' , 'migrateDedicatedHost' , args = (999 ), identifier = 100 )
850+
851+ def test_vs_migrate_exception (self ):
852+ ex = SoftLayerAPIError ('SoftLayer_Exception' , 'PROBLEM' )
853+ mock = self .set_mock ('SoftLayer_Virtual_Guest' , 'migrate' )
854+ mock .side_effect = ex
855+ result = self .run_command (['vs' , 'migrate' , '-g' , '100' ])
856+ self .assert_no_fail (result )
857+ self .assertIn ('Failed to migrate' , result .output )
858+ self .assert_not_called_with ('SoftLayer_Account' , 'getVirtualGuests' )
859+ self .assert_called_with ('SoftLayer_Virtual_Guest' , 'migrate' , identifier = 100 )
860+ self .assert_not_called_with ('SoftLayer_Virtual_Guest' , 'migrateDedicatedHost' , args = (999 ), identifier = 100 )
0 commit comments