<s> from __future__ import print_function , absolute_import <EOL> from authcode import wsgi <EOL> import pytest <EOL> from . helpers import wsgi_tester <EOL> request = None <EOL> def make_wepapp ( ) : <EOL> from werkzeug . exceptions import HTTPException <EOL> from werkzeug . routing import Map , Rule <EOL> from werkzeug . serving import run_simple <EOL> from werkzeug . wrappers import Request , Response <EOL> class Application ( object ) : <EOL> def __init__ ( self ) : <EOL> self . url_map = Map ( [ <EOL> Rule ( '<STR_LIT>' , endpoint = '<STR_LIT>' ) , <EOL> Rule ( '<STR_LIT>' , endpoint = '<STR_LIT>' ) , <EOL> Rule ( '<STR_LIT>' , endpoint = '<STR_LIT>' ) , <EOL> Rule ( '<STR_LIT>' , endpoint = '<STR_LIT>' ) , <EOL> Rule ( '<STR_LIT>' , endpoint = '<STR_LIT>' ) , <EOL> Rule ( '<STR_LIT>' , endpoint = '<STR_LIT>' ) , <EOL> Rule ( '<STR_LIT>' , endpoint = '<STR_LIT>' ) , <EOL> Rule ( '<STR_LIT>' , endpoint = '<STR_LIT>' ) , <EOL> Rule ( '<STR_LIT>' , endpoint = '<STR_LIT>' ) , <EOL> Rule ( '<STR_LIT>' , endpoint = '<STR_LIT>' ) , <EOL> Rule ( '<STR_LIT>' , endpoint = '<STR_LIT>' ) , <EOL> Rule ( '<STR_LIT>' , endpoint = '<STR_LIT>' ) , <EOL> ] ) <EOL> def __call__ ( self , environ , start_response ) : <EOL> return self . wsgi_app ( environ , start_response ) <EOL> def wsgi_app ( self , environ , start_response ) : <EOL> request = Request ( environ ) <EOL> response = self . dispatch_request ( request ) <EOL> if not isinstance ( response , Response ) : <EOL> response = Response ( response ) <EOL> return response ( environ , start_response ) <EOL> def dispatch_request ( self , request ) : <EOL> try : <EOL> adapter = self . url_map . bind_to_environ ( request . environ ) <EOL> endpoint , values = adapter . match ( ) <EOL> return getattr ( self , '<STR_LIT>' + endpoint ) ( request , ** values ) <EOL> except HTTPException as e : <EOL> return Response ( str ( e ) , status = e . code ) <EOL> def on_get_site_name ( self , request ) : <EOL> return wsgi . werkzeug . get_site_name ( request ) <EOL> def on_get_full_path ( self , request ) : <EOL> return wsgi . werkzeug . get_full_path ( request ) <EOL> def on_make_full_url ( self , request ) : <EOL> return wsgi . werkzeug . make_full_url ( request , '<STR_LIT>' ) <EOL> def on_is_post ( self , request ) : <EOL> return '<STR_LIT:yes>' if wsgi . werkzeug . is_post ( request ) else '<STR_LIT>' <EOL> def on_is_idempotent ( self , request ) : <EOL> return '<STR_LIT:yes>' if wsgi . werkzeug . is_idempotent ( request ) else '<STR_LIT>' <EOL> def on_redirect ( self , request ) : <EOL> return wsgi . werkzeug . redirect ( '<STR_LIT>' ) <EOL> def on_redirected_to ( self , request ) : <EOL> return u'<STR_LIT>' <EOL> def on_raise_forbidden ( self , request ) : <EOL> return wsgi . werkzeug . raise_forbidden ( '<STR_LIT>' ) <EOL> def on_get_from_params ( self , request ) : <EOL> return wsgi . werkzeug . get_from_params ( request , '<STR_LIT:foo>' ) <EOL> def on_get_from_headers ( self , request ) : <EOL> return wsgi . werkzeug . get_from_headers ( request , '<STR_LIT>' ) <EOL> def on_get_post_data ( self , request ) : <EOL> data = wsgi . werkzeug . get_post_data ( request ) <EOL> return '<STR_LIT>' . format ( <EOL> val1 = data . get ( '<STR_LIT>' ) , <EOL> val2 = data . get ( '<STR_LIT>' ) <EOL> ) <EOL> def on_make_response ( self , request ) : <EOL> body = '<STR_LIT>' <EOL> mime = '<STR_LIT:application/json>' <EOL> return wsgi . werkzeug . make_response ( body , mime ) <EOL> app = Application ( ) <EOL> run_simple ( '<STR_LIT>' , <NUM_LIT> , app , use_debugger = False , use_reloader = False ) <EOL> @ pytest . mark . slow <EOL> def test_wsgi_werkzeug ( ) : <EOL> wsgi_tester ( make_wepapp , <NUM_LIT> ) </s>
