#NEWLINE# @ mock . patch ( 'rally.cli.commands.task.sys.stdout' ) #NEWLINE# @ mock . patch ( 'rally.cli.commands.task.api.Task.get' ) #NEWLINE# def test_results_no_data( self , mock_task_get , mock_stdout ) : #NEWLINE# #INDENT# task_id = 'foo_task_id' #NEWLINE# fake_task = fakes . FakeTask ( { #NEWLINE# #INDENT# 'status' : consts . TaskStatus . FAILED , #NEWLINE# #UNINDENT# } ) #NEWLINE# mock_task_get . return_value = fake_task #NEWLINE# self . assertEqual ( 1 , self . task . results ( task_id ) ) #NEWLINE# mock_task_get . assert_called_once_with ( mock_task_get ) #NEWLINE# expected_out = ( 'Task status is %s. Results available when it is one of %s.' % ( consts . TaskStatus . FAILED , ', ' . join ( ( consts . TaskStatus . FINISHED , consts . TaskStatus . ABORTED ) ) ) ) #NEWLINE# mock_stdout . write . assert_has_calls ( [ mock . call ( expected_out ) ] )