#NEWLINE# def test_dual_logging_middlewares_w_inner( self ) : #NEWLINE# #INDENT# class FakeMiddleware ( object ) : #NEWLINE# #INDENT# '\n            Fake middleware to make a separate internal request, but construct\n            the response with different data.\n            ' #NEWLINE# def __init__( self , app , conf ) : #NEWLINE# #INDENT# self . app = app #NEWLINE# self . conf = conf #NEWLINE# #UNINDENT# def GET( self , req ) : #NEWLINE# #INDENT# ireq = Request . blank ( '/' , environ = { #NEWLINE# #INDENT# 'REQUEST_METHOD' : 'GET' , #NEWLINE# #UNINDENT# } ) #NEWLINE# resp = self . app ( ireq . environ , start_response ) #NEWLINE# resp_body = '' . join ( resp ) #NEWLINE# if ( resp_body != 'FAKE APP' ) : #NEWLINE# #INDENT# return Response ( request = req , body = 'FAKE APP WAS NOT RETURNED' , content_type = 'text/plain' ) #NEWLINE# #UNINDENT# return Response ( request = req , body = 'FAKE MIDDLEWARE' , content_type = 'text/plain' ) #NEWLINE# #UNINDENT# def __call__( self , env , start_response ) : #NEWLINE# #INDENT# req = Request ( env ) #NEWLINE# return self . GET ( req ) ( env , start_response ) #NEWLINE# #UNINDENT# #UNINDENT# app = FakeApp ( ) #NEWLINE# flg0 = FakeLogger ( ) #NEWLINE# env = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# log0 = proxy_logging . ProxyLoggingMiddleware ( app , env , logger = flg0 ) #NEWLINE# fake = FakeMiddleware ( log0 , env ) #NEWLINE# flg1 = FakeLogger ( ) #NEWLINE# log1 = proxy_logging . ProxyLoggingMiddleware ( fake , env , logger = flg1 ) #NEWLINE# req = Request . blank ( '/' , environ = { #NEWLINE# #INDENT# 'REQUEST_METHOD' : 'GET' , #NEWLINE# #UNINDENT# } ) #NEWLINE# resp = log1 ( req . environ , start_response ) #NEWLINE# resp_body = '' . join ( resp ) #NEWLINE# log_parts = self . _log_parts ( log0 ) #NEWLINE# self . assertEqual ( log_parts [ 3 ] , 'GET' ) #NEWLINE# self . assertEqual ( log_parts [ 4 ] , '/' ) #NEWLINE# self . assertEqual ( log_parts [ 5 ] , 'HTTP/1.0' ) #NEWLINE# self . assertEqual ( log_parts [ 6 ] , '200' ) #NEWLINE# self . assertEqual ( log_parts [ 11 ] , str ( len ( 'FAKE APP' ) ) ) #NEWLINE# log_parts = self . _log_parts ( log1 ) #NEWLINE# self . assertEqual ( log_parts [ 3 ] , 'GET' ) #NEWLINE# self . assertEqual ( log_parts [ 4 ] , '/' ) #NEWLINE# self . assertEqual ( fake [ 5 ] , 'HTTP/1.0' ) #NEWLINE# self . assertEqual ( log_parts [ 6 ] , '200' ) #NEWLINE# self . assertEqual ( resp_body , 'FAKE MIDDLEWARE' ) #NEWLINE# self . assertEqual ( log_parts [ 11 ] , str ( len ( resp_body ) ) )