#NEWLINE# def test_load_app( self ) : #NEWLINE# #INDENT# config = '\n        [DEFAULT]\n        swift_dir = TEMPDIR\n\n        [pipeline:main]\n        pipeline = healthcheck proxy-server\n\n        [app:proxy-server]\n        use = egg:swift#proxy\n        conn_timeout = 0.2\n\n        [filter:catch_errors]\n        use = egg:swift#catch_errors\n\n        [filter:healthcheck]\n        use = egg:swift#healthcheck\n        ' #NEWLINE# def modify_func( app , pipe ) : #NEWLINE# #INDENT# new = pipe . create_filter ( 'catch_errors' ) #NEWLINE# pipe . insert_filter ( new ) #NEWLINE# #UNINDENT# contents = dedent ( config ) #NEWLINE# with temptree ( [ 'proxy-server.conf' ] ) as t : #NEWLINE# #INDENT# conf_file = os . path . join ( t , 'proxy-server.conf' ) #NEWLINE# with open ( conf_file , 'w' ) as f : #NEWLINE# #INDENT# f . write ( contents . replace ( 'TEMPDIR' , t ) ) #NEWLINE# #UNINDENT# _fake_rings ( t ) #NEWLINE# with mock . patch ( 'swift.proxy.server.Application.modify_wsgi_pipeline' , modify_func ) : #NEWLINE# #INDENT# app = wsgi . loadapp ( conf_file , global_conf = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# exp = swift . common . middleware . catch_errors . CatchErrorMiddleware #NEWLINE# self . assertTrue ( isinstance ( app , exp ) , app ) #NEWLINE# exp = swift . common . middleware . healthcheck . HealthCheckMiddleware #NEWLINE# self . assertTrue ( isinstance ( app . app , exp ) , app . app ) #NEWLINE# exp = swift . proxy . server . Application #NEWLINE# self . assertTrue ( isinstance ( app . app . app , exp ) , app . app . app ) #NEWLINE# def blow_up( * _ , **__ ) : #NEWLINE# #INDENT# raise self . fail ( 'needs more struts' ) #NEWLINE# #UNINDENT# with mock . patch ( 'swift.proxy.server.Application.modify_wsgi_pipeline' , blow_up ) : #NEWLINE# #INDENT# app = wsgi . loadapp ( conf_file , global_conf = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , allow_modify_pipeline = False ) #NEWLINE# #UNINDENT# exp = swift . common . middleware . healthcheck . HealthCheckMiddleware #NEWLINE# self . assertTrue ( isinstance ( app , exp ) , app ) #NEWLINE# exp = swift . proxy . server . Application #NEWLINE# self . assertTrue ( isinstance ( app . app , exp ) , app . app )