#NEWLINE# @ mock . patch ( 'nailgun.task.task.rpc' ) #NEWLINE# @ mock . patch ( 'nailgun.task.task.make_astute_message' ) #NEWLINE# def test_astute_message_creation( self , mmake_astute_message , mrpc ) : #NEWLINE# #INDENT# n_discover = self . add_node ( consts . NODE_STATUSES . discover ) #NEWLINE# self . add_node ( consts . NODE_STATUSES . ready ) #NEWLINE# self . add_node ( consts . NODE_STATUSES . ready , online = False ) #NEWLINE# nodes = DeletionTask . get_task_nodes_for_cluster ( self . cluster_db ) #NEWLINE# astute_nodes = [ node for node in nodes [ 'nodes_to_delete' ] if ( node [ 'id' ] != n_discover . id ) ] #NEWLINE# self . assertEqual ( len ( nodes [ 'nodes_to_delete' ] ) , 3 ) #NEWLINE# self . assertEqual ( len ( nodes [ 'nodes_to_restore' ] ) , 0 ) #NEWLINE# task = models . Task ( name = consts . TASK_NAMES . cluster_deletion , cluster = self . cluster_db ) #NEWLINE# db ( ) . add ( task ) #NEWLINE# db ( ) . commit ( ) #NEWLINE# DeletionTask . execute ( task , nodes = nodes ) #NEWLINE# self . assertEqual ( mmake_astute_message . call_count , 1 ) #NEWLINE# message = mmake_astute_message . call_args [ 0 ] [ 3 ] #NEWLINE# self . assertIn ( 'nodes' , message ) #NEWLINE# self . assertItemsEqual ( message [ 'nodes' ] , astute_nodes ) #NEWLINE# self . assertEqual ( mrpc . cast . call_count , 1 )