#NEWLINE# def _verify_reboot( self , soft = True ) : #NEWLINE# #INDENT# actions = [ { #NEWLINE# #INDENT# ( 'soft_reboot' if soft else 'hard_reboot' ) : 5 , #NEWLINE# #UNINDENT# } ] #NEWLINE# fake_server = mock . MagicMock ( ) #NEWLINE# scenario = servers . NovaServers ( self . context ) #NEWLINE# scenario . _reboot_server = mock . MagicMock ( ) #NEWLINE# scenario . _soft_reboot_server = mock . MagicMock ( ) #NEWLINE# scenario . _boot_server = mock . MagicMock ( return_value = fake_server ) #NEWLINE# scenario . _delete_server = mock . MagicMock ( ) #NEWLINE# scenario . generate_random_name = mock . MagicMock ( return_value = 'name' ) #NEWLINE# scenario . boot_and_bounce_server ( 'img' , 1 , actions = actions ) #NEWLINE# scenario . _boot_server . assert_called_once_with ( 'img' , 1 ) #NEWLINE# server_calls = [ ] #NEWLINE# for i in range ( 5 ) : #NEWLINE# #INDENT# server_calls . append ( mock . call ( fake_server ) ) #NEWLINE# #UNINDENT# if soft : #NEWLINE# #INDENT# self . assertEqual ( 5 , scenario . _soft_reboot_server . call_count , 'Reboot not called 5 times' ) #NEWLINE# scenario . _soft_reboot_server . assert_has_calls ( server_calls ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . assertEqual ( 5 , fake_server . _reboot_server . call_count , 'Reboot not called 5 times' ) #NEWLINE# scenario . _reboot_server . assert_has_calls ( server_calls ) #NEWLINE# #UNINDENT# scenario . _delete_server . assert_called_once_with ( fake_server , force = False )