@@ -341,25 +341,39 @@ def test_create_verify_no_price_or_more_than_one(self):
341341 @mock .patch ('SoftLayer.DedicatedHostManager.cancel_host' )
342342 def test_cancel_host (self , cancel_mock ):
343343 result = self .run_command (['--really' , 'dedicatedhost' , 'cancel' , '12345' ])
344+
344345 self .assert_no_fail (result )
345346 cancel_mock .assert_called_with (12345 )
347+
346348 self .assertEqual (str (result .output ), 'Dedicated Host 12345 was cancelled\n ' )
347349
348350 def test_cancel_host_abort (self ):
349351 result = self .run_command (['dedicatedhost' , 'cancel' , '12345' ])
350352 self .assertEqual (result .exit_code , 2 )
351353 self .assertIsInstance (result .exception , exceptions .CLIAbort )
352354
353- @mock .patch ('SoftLayer.DedicatedHostManager.cancel_host' )
354- def test_cancel_all_guest (self , cancel_mock ):
355- result = self .run_command (['--really' , 'dedicatedhost' , 'cancel' , '12345' ])
355+ def test_cancel_all_guests (self ):
356+ guests = self .set_mock ('SoftLayer_Virtual_DedicatedHost' , 'getGuests' )
357+ guests .return_value = [{'id' : 987 }, {'id' : 654 }]
358+
359+ result = self .run_command (['--really' , 'dedicatedhost' , 'cancel-all-guests' , '12345' ])
356360 self .assert_no_fail (result )
357- cancel_mock .assert_called_with (12345 )
358- self .assertEqual (str (result .output ), 'Dedicated Host 12345 was cancelled\n ' )
359361
360- def test_cancel_all_guest_empty_list (self ):
362+ self .assertEqual (str (result .output ), 'All guests into the dedicated host 12345 were cancelled\n ' )
363+
364+ def test_cancel_all_guests_empty_list (self ):
365+ guests = self .set_mock ('SoftLayer_Virtual_DedicatedHost' , 'getGuests' )
366+ guests .return_value = []
367+
368+ result = self .run_command (['--really' , 'dedicatedhost' , 'cancel-all-guests' , '12345' ])
369+ self .assert_no_fail (result )
370+
371+ self .assertEqual (str (result .output ), 'There is not any guest into the dedicated host 12345\n ' )
372+
373+ def test_cancel_all_guests_abort (self ):
361374 result = self .run_command (['dedicatedhost' , 'cancel' , '12345' ])
362375 self .assertEqual (result .exit_code , 2 )
376+
363377 self .assertIsInstance (result .exception , exceptions .CLIAbort )
364378
365379 def test_list_guests (self ):
@@ -370,12 +384,12 @@ def test_list_guests(self):
370384 [{'hostname' : 'vs-test1' ,
371385 'domain' : 'test.sftlyr.ws' ,
372386 'primary_ip' : '172.16.240.2' ,
373- 'id' : 100 ,
387+ 'id' : 200 ,
374388 'power_state' : 'Running' ,
375389 'backend_ip' : '10.45.19.37' },
376390 {'hostname' : 'vs-test2' ,
377391 'domain' : 'test.sftlyr.ws' ,
378392 'primary_ip' : '172.16.240.7' ,
379- 'id' : 104 ,
393+ 'id' : 202 ,
380394 'power_state' : 'Running' ,
381395 'backend_ip' : '10.45.19.35' }])
0 commit comments