#NEWLINE# @ fake_tasks ( ) #NEWLINE# def test_deployment_on_controller_removal_via_node_deletion( self ) : #NEWLINE# #INDENT# cluster = self . env . create ( nodes_kwargs = [ { #NEWLINE# #INDENT# 'roles' : [ 'controller' ] , #NEWLINE# 'status' : consts . NODE_STATUSES . ready , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'roles' : [ 'controller' ] , #NEWLINE# 'status' : consts . NODE_STATUSES . ready , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'roles' : [ 'controller' ] , #NEWLINE# 'status' : consts . NODE_STATUSES . ready , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'roles' : [ 'compute' ] , #NEWLINE# 'status' : consts . NODE_STATUSES . ready , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'roles' : [ 'compute' ] , #NEWLINE# 'status' : consts . NODE_STATUSES . ready , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# controllers = filter ( ( lambda n : ( ( 'controller' in n . roles ) and ( not n . pending_deletion ) ) ) , cluster . nodes ) #NEWLINE# controller_to_delete = _ [ 0 ] #NEWLINE# expected_nodes_to_deploy = controllers [ 1 : ] #NEWLINE# with mock . patch ( 'nailgun.task.task.DeploymentTask.message' ) as mocked_task : #NEWLINE# #INDENT# with mock . patch ( 'nailgun.rpc.cast' ) : #NEWLINE# #INDENT# resp = self . app . delete ( reverse ( 'NodeHandler' , kwargs = { #NEWLINE# #INDENT# 'obj_id' : controller_to_delete . id , #NEWLINE# #UNINDENT# } ) , headers = self . default_headers ) #NEWLINE# ( _ , actual_nodes_to_deploy ) = mocked_task . call_args [ 0 ] #NEWLINE# self . assertItemsEqual ( expected_nodes_to_deploy , actual_nodes_to_deploy ) #NEWLINE# self . assertEqual ( 202 , resp . status_code )