#NEWLINE# def test_one_file_upload( self ) : #NEWLINE# #INDENT# content = open ( path ( 'test.file' ) , 'rb' ) . read ( ) #NEWLINE# files = { #NEWLINE# #INDENT# 'test.file' : ( b'test.file' , b'test.file' , content ) , #NEWLINE# #UNINDENT# } #NEWLINE# r = urlfetch . post ( testlib . test_server_host , files = { #NEWLINE# #INDENT# 'test.file' : ( 'test.file' , content ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# o = json . loads ( r . text ) #NEWLINE# self . assertEqual ( r . status , 200 ) #NEWLINE# self . assertTrue ( isinstance ( r . json , dict ) ) #NEWLINE# self . assertTrue ( isinstance ( r . text , urlfetch . unicode ) ) #NEWLINE# self . assertEqual ( o [ 'method' ] , 'POST' ) #NEWLINE# self . assertEqual ( sorted ( o [ 'files' ] . keys ( ) ) , sorted ( files . keys ( ) ) ) #NEWLINE# for i in files : #NEWLINE# #INDENT# self . assertEqual ( o [ 'files' ] [ i ] [ 0 ] . encode ( 'utf8' ) , r [ i ] [ 0 ] ) #NEWLINE# self . assertEqual ( o [ 'files' ] [ i ] [ 1 ] . encode ( 'utf8' ) , files [ i ] [ 1 ] ) #NEWLINE# self . assertEqual ( o [ 'files' ] [ i ] [ 2 ] . encode ( 'utf8' ) , md5sum ( files [ i ] [ 2 ] ) )