#NEWLINE# def test_traject_consume_parameter( ) : #NEWLINE# #INDENT# class app ( morepath . App ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# dectate . commit ( app ) #NEWLINE# traject = app . config . path_registry #NEWLINE# class Model ( object ) : #NEWLINE# #INDENT# def __init__( self , a ) : #NEWLINE# #INDENT# self . a = a #NEWLINE# #UNINDENT# #UNINDENT# get_param = ParameterFactory ( { #NEWLINE# #INDENT# 'a' : 0 , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'a' : Converter ( int ) , #NEWLINE# #UNINDENT# } , [ ] ) #NEWLINE# traject . add_pattern ( 'sub' , ( Model , get_param ) ) #NEWLINE# mount = app ( ) #NEWLINE# ( found , request ) = consume ( mount , 'sub?a=1' ) #NEWLINE# assert isinstance ( found , Model ) #NEWLINE# assert ( found . a == 1 ) #NEWLINE# assert ( request . unconsumed == [ ] ) #NEWLINE# ( found , request ) = consume ( mount , 'sub' ) #NEWLINE# assert isinstance ( found , Model ) #NEWLINE# assert ( found . a == 0 ) #NEWLINE# assert ( mount . unconsumed == [ ] )