#NEWLINE# def test_register_path_with_parameters( ) : #NEWLINE# #INDENT# class App ( morepath . App ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# root = Root ( ) #NEWLINE# def get_model( id , param = 'default' ) : #NEWLINE# #INDENT# model = Model ( ) #NEWLINE# model . id = id #NEWLINE# model . param = param #NEWLINE# return model #NEWLINE# #UNINDENT# dectate . commit ( App ) #NEWLINE# path_registry = App . config . path_registry #NEWLINE# path_registry . register_path ( Root , '' , ( lambda m : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) , None , None , None , False , ( lambda : root ) ) #NEWLINE# path_registry . register_path ( Model , '{id}' , ( lambda model : { #NEWLINE# #INDENT# 'id' : model . id , #NEWLINE# 'param' : model . param , #NEWLINE# #UNINDENT# } ) , None , None , None , False , get_model ) #NEWLINE# mount = App ( ) #NEWLINE# ( obj , request ) = consume ( mount , 'a' ) #NEWLINE# assert ( obj . id == 'a' ) #NEWLINE# assert ( obj . param == 'default' ) #NEWLINE# ( obj , request ) = consume ( mount , 'a' , { #NEWLINE# #INDENT# 'param' : 'value' , #NEWLINE# #UNINDENT# } ) #NEWLINE# assert ( obj . id == 'a' ) #NEWLINE# assert ( obj . param == 'value' ) #NEWLINE# model = Model ( ) #NEWLINE# model . id = 'b' #NEWLINE# model . param = 'other' #NEWLINE# info = mount . _get_path ( model ) #NEWLINE# assert ( info . path == 'b' ) #NEWLINE# assert ( info . parameters == { #NEWLINE# #INDENT# 'param' : [ 'other' ] , #NEWLINE# #UNINDENT# } )