#NEWLINE# def test_request_view( self ) : #NEWLINE# #INDENT# 'Test the request stats view' #NEWLINE# request_patcher = mock . patch ( 'flaskext.gae_mini_profiler.request' , spec = True ) #NEWLINE# profiler_patcher = mock . patch ( 'flaskext.gae_mini_profiler.profiler' , spec = True ) #NEWLINE# jsonify_patcher = mock . patch ( 'flaskext.gae_mini_profiler.jsonify' , spec = True ) #NEWLINE# request = request_patcher . start ( ) #NEWLINE# profiler = profiler_patcher . start ( ) #NEWLINE# jsonify = jsonify_patcher . start ( ) #NEWLINE# try : #NEWLINE# #INDENT# from flaskext.gae_mini_profiler import GAEMiniProfiler #NEWLINE# properties = [ 'a' , 'b' , 'c' ] #NEWLINE# request_ids = [ '1' , '2' , '3' ] #NEWLINE# request . args = { #NEWLINE# #INDENT# 'request_ids' : ',' . join ( request_ids ) , #NEWLINE# #UNINDENT# } #NEWLINE# stats = profiler . RequestStats . get . return_value #NEWLINE# stats . __getattribute__ = ( lambda x : x ) #NEWLINE# stats . disabled = False #NEWLINE# stats . temporary_redirect = False #NEWLINE# profiler . RequestStats . serialized_properties = properties #NEWLINE# app = mock . Mock ( ) #NEWLINE# ext = GAEMiniProfiler ( app ) #NEWLINE# ext . _request_view ( ) #NEWLINE# self . assertEquals ( len ( request_ids ) , profiler . RequestStats . get . call_count ) #NEWLINE# expected_result = [ ] #NEWLINE# for id in request_ids : #NEWLINE# #INDENT# expected_result . append ( dict ( zip ( request_ids , properties ) ) ) #NEWLINE# #UNINDENT# jsonify . assert_called_once_with ( stats = expected_result ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# request_patcher . stop ( ) #NEWLINE# profiler_patcher . stop ( ) #NEWLINE# jsonify_patcher . stop ( )