#NEWLINE# @ mock . patch ( 'json.dumps' ) #NEWLINE# @ mock . patch ( 'rally.cli.commands.task.api.Task.get' ) #NEWLINE# def test_results( self , mock_task_get , mock_json_dumps ) : #NEWLINE# #INDENT# task_id = 'foo_task_id' #NEWLINE# data = [ { #NEWLINE# #INDENT# 'key' : 'foo_key' , #NEWLINE# 'data' : { #NEWLINE# #INDENT# 'raw' : 'foo_raw' , #NEWLINE# 'sla' : [ ] , #NEWLINE# 'load_duration' : 1.0 , #NEWLINE# 'full_duration' : 2.0 , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ] #NEWLINE# result = map ( ( lambda x : { #NEWLINE# #INDENT# 'key' : x [ 'key' ] , #NEWLINE# 'result' : x [ 'data' ] [ 'raw' ] , #NEWLINE# 'load_duration' : x [ 'data' ] [ 'load_duration' ] , #NEWLINE# 'full_duration' : x [ 'data' ] [ 'full_duration' ] , #NEWLINE# 'sla' : x [ 'data' ] [ 'sla' ] , #NEWLINE# #UNINDENT# } ) , data ) #NEWLINE# fake_task = fakes . FakeTask ( { #NEWLINE# #INDENT# 'status' : consts . TaskStatus . FINISHED , #NEWLINE# #UNINDENT# } ) #NEWLINE# fake_task . get_results = mock . MagicMock ( return_value = data ) #NEWLINE# mock_task_get . return_value = fake_task #NEWLINE# self . task . results ( task_id ) #NEWLINE# self . assertEqual ( 1 , mock_json_dumps . call_count ) #NEWLINE# self . assertEqual ( 1 , len ( mock_json_dumps . call_args [ 0 ] ) ) #NEWLINE# self . assertSequenceEqual ( result , mock_json_dumps . call_args [ 0 ] [ 0 ] ) #NEWLINE# self . assertEqual ( { #NEWLINE# #INDENT# 'sort_keys' : True , #NEWLINE# 'indent' : 4 , #NEWLINE# #UNINDENT# } , mock_json_dumps . call_args [ 1 ] ) #NEWLINE# mock_task_get . assert_called_once_with ( self )