#NEWLINE# @ mock . patch ( 'nailgun.task.task.rpc.cast' ) #NEWLINE# @ mock . patch ( 'objects.Cluster.get_deployment_tasks' ) #NEWLINE# def test_only_certain_tasks_run_in_deploy( self , tasks_mock , rpc_mock ) : #NEWLINE# #INDENT# task = { #NEWLINE# #INDENT# 'id' : 'test' , #NEWLINE# 'parameters' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'type' : 'puppet' , #NEWLINE# 'roles' : [ 'master' ] , #NEWLINE# 'version' : '2.1.0' , #NEWLINE# #UNINDENT# } #NEWLINE# tasks = [ ] #NEWLINE# for i in range ( 5 ) : #NEWLINE# #INDENT# task_copy = task . copy ( ) #NEWLINE# task_copy [ 'id' ] = ( 'test' + str ( i ) ) #NEWLINE# tasks . append ( task_copy ) #NEWLINE# #UNINDENT# tasks_mock . return_value = tasks #NEWLINE# self . env . create ( nodes_kwargs = [ { #NEWLINE# #INDENT# 'status' : NODE_STATUSES . provisioned , #NEWLINE# 'roles' : [ 'controller' ] , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'status' : NODE_STATUSES . provisioned , #NEWLINE# 'roles' : [ 'compute' ] , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'status' : NODE_STATUSES . provisioned , #NEWLINE# 'roles' : [ 'cinder' ] , #NEWLINE# #UNINDENT# } ] , release_kwargs = { #NEWLINE# #INDENT# 'operating_system' : consts . RELEASE_OS . ubuntu , #NEWLINE# 'version' : 'mitaka-9.0' , #NEWLINE# #UNINDENT# } ) #NEWLINE# cluster = self . env . clusters [ ( - 1 ) ] #NEWLINE# task_ids = [ 'test0' , 'test3' ] #NEWLINE# task = self . env . launch_deployment_selected_tasks ( [ n . uid for n in cluster . nodes ] , cluster . id , task_ids ) #NEWLINE# self . assertNotEqual ( consts . TASK_STATUSES . error , task . status ) #NEWLINE# tasks_graph = rpc_mock . call_args [ 0 ] [ 1 ] [ 'args' ] [ 'tasks_graph' ] #NEWLINE# for task in tasks_graph [ 'master' ] : #NEWLINE# #INDENT# if ( task_ids [ 'id' ] in task_ids ) : #NEWLINE# #INDENT# self . assertEqual ( task [ 'type' ] , 'puppet' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . assertEqual ( task [ 'type' ] , 'skipped' )