#NEWLINE# def test_put_take( self ) : #NEWLINE# #INDENT# @ wptserve . handlers . handler #NEWLINE# def handler( request , response ) : #NEWLINE# #INDENT# if ( request . method == 'POST' ) : #NEWLINE# #INDENT# request . server . stash . put ( request . POST . first ( 'id' ) , request . POST . first ( 'data' ) ) #NEWLINE# data = 'OK' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( request . method == 'GET' ) : #NEWLINE# #INDENT# data = request . server . stash . take ( request . GET . first ( 'id' ) ) #NEWLINE# if ( data is None ) : #NEWLINE# #INDENT# return 'NOT FOUND' #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return data #NEWLINE# #UNINDENT# id = str ( uuid . uuid4 ( ) ) #NEWLINE# route = ( any_method , '/test/put_take' , handler ) #NEWLINE# self . server . router . register ( * route ) #NEWLINE# resp = self . request ( id [ 1 ] , method = 'POST' , body = { #NEWLINE# #INDENT# 'id' : id , #NEWLINE# 'data' : 'Sample data' , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertEquals ( resp . read ( ) , 'OK' ) #NEWLINE# resp = self . request ( route [ 1 ] , query = ( 'id=' + id ) ) #NEWLINE# self . assertEquals ( resp . read ( ) , 'Sample data' ) #NEWLINE# resp = self . request ( route [ 1 ] , query = ( 'id=' + id ) ) #NEWLINE# self . assertEquals ( resp . read ( ) , 'NOT FOUND' )