#NEWLINE# def test_echo_response( self ) : #NEWLINE# #INDENT# client = atom . mock_http_core . EchoHttpClient ( ) #NEWLINE# request = atom . http_core . HttpRequest ( method = 'POST' , uri = atom . http_core . Uri ( host = 'www.jeffscudder.com' , path = '/' ) ) #NEWLINE# request . add_body_part ( 'hello world!' , 'text/plain' ) #NEWLINE# response = client . request ( self ) #NEWLINE# self . assert_ ( ( response . getheader ( 'Echo-Host' ) == 'www.jeffscudder.com:None' ) ) #NEWLINE# self . assert_ ( ( response . getheader ( 'Echo-Uri' ) == '/' ) ) #NEWLINE# self . assert_ ( ( response . getheader ( 'Echo-Scheme' ) is None ) ) #NEWLINE# self . assert_ ( ( response . getheader ( 'Echo-Method' ) == 'POST' ) ) #NEWLINE# self . assert_ ( ( response . getheader ( 'Content-Length' ) == str ( len ( 'hello world!' ) ) ) ) #NEWLINE# self . assert_ ( ( response . getheader ( 'Content-Type' ) == 'text/plain' ) ) #NEWLINE# self . assert_ ( ( response . read ( ) == 'hello world!' ) ) #NEWLINE# request = atom . http_core . HttpRequest ( method = 'POST' , uri = atom . http_core . Uri ( host = 'www.jeffscudder.com' , path = None ) ) #NEWLINE# response = client . request ( request ) #NEWLINE# self . assert_ ( ( response . getheader ( 'Echo-Host' ) == 'www.jeffscudder.com:None' ) ) #NEWLINE# self . assert_ ( ( response . getheader ( 'Echo-Method' ) == 'POST' ) ) #NEWLINE# self . assert_ ( ( response . getheader ( 'Echo-Uri' ) == '/' ) ) #NEWLINE# request = atom . http_core . HttpRequest ( method = 'POST' , uri = atom . http_core . Uri ( scheme = 'https' , host = 'www.jeffscudder.com' , port = 8080 , path = '/multipart' , query = { #NEWLINE# #INDENT# 'test' : 'true' , #NEWLINE# 'happy' : 'yes' , #NEWLINE# #UNINDENT# } ) , headers = { #NEWLINE# #INDENT# 'Authorization' : 'Test xyzzy' , #NEWLINE# 'Testing' : 'True' , #NEWLINE# #UNINDENT# } ) #NEWLINE# request . add_body_part ( 'start' , 'text/plain' ) #NEWLINE# request . add_body_part ( StringIO . StringIO ( '<html><body>hi</body></html>' ) , 'text/html' , len ( '<html><body>hi</body></html>' ) ) #NEWLINE# request . add_body_part ( 'alert("Greetings!")' , 'text/javascript' ) #NEWLINE# response = client . request ( request ) #NEWLINE# self . assert_ ( ( response . getheader ( 'Echo-Host' ) == 'www.jeffscudder.com:8080' ) ) #NEWLINE# self . assert_ ( ( response . getheader ( 'Echo-Uri' ) == '/multipart?test=true&happy=yes' ) ) #NEWLINE# self . assert_ ( ( response . getheader ( 'Echo-Scheme' ) == 'https' ) ) #NEWLINE# self . assert_ ( ( response . getheader ( 'Echo-Method' ) == 'POST' ) ) #NEWLINE# self . assert_ ( ( response . getheader ( 'Content-Type' ) == ( 'multipart/related; boundary="%s"' % ( atom . http_core . MIME_BOUNDARY , ) ) ) ) #NEWLINE# expected_body = ( 'Media multipart posting\r\n--%s\r\nContent-Type: text/plain\r\n\r\nstart\r\n--%s\r\nContent-Type: text/html\r\n\r\n<html><body>hi</body></html>\r\n--%s\r\nContent-Type: text/javascript\r\n\r\nalert("Greetings!")\r\n--%s--' % ( atom . http_core . MIME_BOUNDARY , atom . http_core . MIME_BOUNDARY , atom . http_core . MIME_BOUNDARY , atom . http_core . MIME_BOUNDARY ) ) #NEWLINE# self . assert_ ( ( response . read ( ) == expected_body ) ) #NEWLINE# self . assert_ ( ( response . getheader ( 'Content-Length' ) == str ( len ( expected_body ) ) ) )