@@ -802,3 +802,65 @@ def test_billing(self):
802802 }
803803 self .assert_no_fail (result )
804804 self .assertEqual (json .loads (result .output ), vir_billing )
805+
806+ def test_vs_migrate_list (self ):
807+ result = self .run_command (['vs' , 'migrate' ])
808+ self .assert_no_fail (result )
809+ self .assert_called_with ('SoftLayer_Account' , 'getVirtualGuests' )
810+ self .assert_not_called_with ('SoftLayer_Virtual_Guest' , 'migrate' )
811+ self .assert_not_called_with ('SoftLayer_Virtual_Guest' , 'migrateDedicatedHost' )
812+
813+ def test_vs_migrate_list_empty (self ):
814+ mock = self .set_mock ('SoftLayer_Account' , 'getVirtualGuests' )
815+ mock .return_value = []
816+ result = self .run_command (['vs' , 'migrate' ])
817+ self .assert_no_fail (result )
818+ self .assert_called_with ('SoftLayer_Account' , 'getVirtualGuests' )
819+ self .assert_not_called_with ('SoftLayer_Virtual_Guest' , 'migrate' )
820+ self .assert_not_called_with ('SoftLayer_Virtual_Guest' , 'migrateDedicatedHost' )
821+ self .assertIn ("No guests require migration at this time" , result .output )
822+
823+ def test_vs_migrate_guest (self ):
824+ result = self .run_command (['vs' , 'migrate' , '-g' , '100' ])
825+ self .assert_no_fail (result )
826+ self .assertIn ('Started a migration on' , result .output )
827+ self .assert_not_called_with ('SoftLayer_Account' , 'getVirtualGuests' )
828+ self .assert_called_with ('SoftLayer_Virtual_Guest' , 'migrate' , identifier = 100 )
829+ self .assert_not_called_with ('SoftLayer_Virtual_Guest' , 'migrateDedicatedHost' )
830+
831+ def test_vs_migrate_all (self ):
832+ result = self .run_command (['vs' , 'migrate' , '-a' ])
833+ self .assert_no_fail (result )
834+ self .assertIn ('Started a migration on' , result .output )
835+ self .assert_called_with ('SoftLayer_Virtual_Guest' , 'migrate' , identifier = 100 )
836+ self .assert_called_with ('SoftLayer_Virtual_Guest' , 'migrate' , identifier = 104 )
837+ self .assert_not_called_with ('SoftLayer_Virtual_Guest' , 'migrateDedicatedHost' )
838+
839+ def test_vs_migrate_all_empty (self ):
840+ mock = self .set_mock ('SoftLayer_Account' , 'getVirtualGuests' )
841+ mock .return_value = []
842+ result = self .run_command (['vs' , 'migrate' , '-a' ])
843+ self .assert_no_fail (result )
844+ self .assertIn ('No guests require migration at this time' , result .output )
845+ self .assert_called_with ('SoftLayer_Virtual_Guest' , 'migrate' , identifier = 100 )
846+ self .assert_called_with ('SoftLayer_Virtual_Guest' , 'migrate' , identifier = 104 )
847+ self .assert_not_called_with ('SoftLayer_Virtual_Guest' , 'migrateDedicatedHost' )
848+
849+ def test_vs_migrate_dedicated (self ):
850+ result = self .run_command (['vs' , 'migrate' , '-g' , '100' , '-h' , '999' ])
851+ self .assert_no_fail (result )
852+ self .assertIn ('Started a migration on' , result .output )
853+ self .assert_not_called_with ('SoftLayer_Account' , 'getVirtualGuests' )
854+ self .assert_not_called_with ('SoftLayer_Virtual_Guest' , 'migrate' , identifier = 100 )
855+ self .assert_not_called_with ('SoftLayer_Virtual_Guest' , 'migrateDedicatedHost' , args = (999 ), identifier = 100 )
856+
857+ def test_vs_migrate_exception (self ):
858+ ex = SoftLayerAPIError ('SoftLayer_Exception' , 'PROBLEM' )
859+ mock = self .set_mock ('SoftLayer_Virtual_Guest' , 'migrate' )
860+ mock .side_effect = ex
861+ result = self .run_command (['vs' , 'migrate' , '-g' , '100' ])
862+ self .assert_no_fail (result )
863+ self .assertIn ('Failed to migrate' , result .output )
864+ self .assert_not_called_with ('SoftLayer_Account' , 'getVirtualGuests' )
865+ self .assert_called_with ('SoftLayer_Virtual_Guest' , 'migrate' , identifier = 100 )
866+ self .assert_not_called_with ('SoftLayer_Virtual_Guest' , 'migrateDedicatedHost' , args = (999 ), identifier = 100 )
0 commit comments