#NEWLINE# def test_basic_single_hook( self ) : #NEWLINE# #INDENT# run_hook = [ ] #NEWLINE# class RootController ( object ) : #NEWLINE# #INDENT# @ expose ( ) #NEWLINE# def index( self ) : #NEWLINE# #INDENT# run_hook . append ( 'inside' ) #NEWLINE# return 'Hello, World!' #NEWLINE# #UNINDENT# #UNINDENT# class SimpleHook ( PecanHook ) : #NEWLINE# #INDENT# def on_route( self , state ) : #NEWLINE# #INDENT# run_hook . append ( 'on_route' ) #NEWLINE# #UNINDENT# def before( self , state ) : #NEWLINE# #INDENT# run_hook . append ( 'before' ) #NEWLINE# #UNINDENT# def after( self , state ) : #NEWLINE# #INDENT# run_hook . append ( 'after' ) #NEWLINE# #UNINDENT# def on_error( self , state , e ) : #NEWLINE# #INDENT# run_hook . append ( 'error' ) #NEWLINE# #UNINDENT# #UNINDENT# app = TestApp ( make_app ( RootController ( ) , hooks = [ SimpleHook ( ) ] ) ) #NEWLINE# response = app . get ( '/' ) #NEWLINE# assert ( response . status_int == 200 ) #NEWLINE# assert ( response . body == b_ ( 'Hello, World!' ) ) #NEWLINE# assert ( len ( run_hook ) == 4 ) #NEWLINE# assert ( run_hook [ 0 ] == 'on_route' ) #NEWLINE# assert ( run_hook [ 1 ] == 'before' ) #NEWLINE# assert ( run_hook [ 2 ] == 'inside' ) #NEWLINE# assert ( run_hook [ 3 ] == 'after' )