Changeset 3313

Show
Ignore:
Timestamp:
12/23/09 11:43:12 (10 years ago)
Author:
yemuru
Message:

Updated tests to work with the new version of httpretrieve and registerhttpcallback

Location:
seattle/trunk/seattlelib/tests/registerhttpcallback_tests
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • seattle/trunk/seattlelib/tests/registerhttpcallback_tests/ut_registerhttpcallback_content.py

    r3253 r3313  
    99 
    1010 
    11 def test_normal_server(httprequest_dictionary): 
     11def test_normal_server(httprequest_dictionary, http_query, http_post): 
    1212  # normal server just sends a message   
    13   return mycontext['msg_sent'] 
     13  return [mycontext['msg_sent'], None] 
    1414    
    1515 
  • seattle/trunk/seattlelib/tests/registerhttpcallback_tests/ut_registerhttpcallback_dictionary_check.py

    r3253 r3313  
    99include registerhttpcallback.repy 
    1010include httpretrieve.repy 
     11include urllib.repy 
    1112 
    1213 
    13 def test_normal_server(httprequest_dictionary): 
     14def test_normal_server(httprequest_dictionary, http_query, http_post): 
    1415  # normal server just sends a message   
    1516 
    1617  # store the http dictionary to check the content 
    1718  mycontext['httprequest_dictionary'] = httprequest_dictionary 
    18   return ' ' 
     19  return [' ', None] 
    1920    
    2021     
     
    2425   
    2526  # used to send post data using the httpretrieve client 
    26   mycontext['posted_data'] = '' 
    27   for i in range(100): 
    28     mycontext['posted_data'] += str(i)   
     27  http_query = {"first": "1st", "second": "2nd"} 
     28  http_post = {"third": "3rd", "fourth": "4th"} 
     29   
    2930 
    3031  # register the callback server 
     
    3637  else: 
    3738    # send a request to receive the content sent from the server 
    38     try:  
    39       recvd_content = httpretrieve_get_string('http://127.0.0.1:12345/fake/path.html?fakequerystring', mycontext['posted_data'])  
     39    try: 
     40 
     41      recvd_content = httpretrieve_get_string('http://127.0.0.1:12345/fake/path.html', http_query, http_post)  
    4042    except Exception, e: 
    4143      raise Exception('httpretrieve raised an exception: ' + str(e)) 
     
    4648       
    4749      # check the essential dictionary content indvidually to see if they are returned to the callback function correctly  
    48       if httprequest_dictionary['Content-Length'] != str(len(mycontext['posted_data'])): 
    49          print 'dictionary content length failed. Actual posted data length: ' + str(len(mycontext['posted_data'])) 
     50      if int(httprequest_dictionary['Content-Length']) != len(urllib_quote_parameters(http_post)): 
     51         print 'dictionary content length failed. Actual posted data length: ' + str(len(urllib_quote_parameters(http_post))) 
    5052         print 'dictionaries content length: ' + str(httprequest_dictionary['Content-Length'])  
    5153 
    52       if httprequest_dictionary['posted_data'] != mycontext['posted_data']: 
    53          print 'dictionary posted_data failed. Actual posted data: ' + mycontext['posted_data'] 
    54          print ', dictionaries posted: ' + str(httprequest_dictionary['Content-Length'])  
     54      if httprequest_dictionary['posted_data'] != urllib_quote_parameters(http_post): 
     55         print 'dictionary posted_data failed. Actual posted data: ' + urllib_quote_parameters(http_post) 
     56         print ', dictionaries posted: ' + str(httprequest_dictionary['posted_data'])  
    5557 
    56       if httprequest_dictionary['http_version'] != 'HTTP/1.1': 
     58      if httprequest_dictionary['http_version'] != 'HTTP/1.0': 
    5759        print 'dictionary http_version failed. Actual http_version: HTTP/1.1, dictionaries http_version: ' + httprequest_dictionary['http_version']  
    5860 
     
    6062        print 'dictionary http_command failed. http_command, Actual http_command: POST, dictionaries http_command: ' + httprequest_dictionary['http_command']  
    6163 
    62       if httprequest_dictionary['Server'] != 'Seattle Testbed':     
    63         print 'dictionary Server failed. Actual Server: Seattle Testbed, dictionaries Server: ' + httprequest_dictionary['Server'] 
    64           
    6564      if httprequest_dictionary['Host'] != '127.0.0.1:12345': 
    6665        print 'dictionary Host failed. Actual Host: 127.0.0.1:12345, dictionaries Host: ' + httprequest_dictionary['http_command'] 
     
    6968        print 'dictionary path failed. Actual path: /fake/path.html, dictionaries path: ' + httprequest_dictionary['path'] 
    7069 
    71       if httprequest_dictionary['query'] != 'fakequerystring': 
    72         print 'dictionary query failed. Actual query: ?fakequerystring, dictionaries query: ' + httprequest_dictionary['query']   
     70      if httprequest_dictionary['query'] != urllib_quote_parameters(http_query): 
     71        print 'dictionary query failed. Actual query: ' + urllib_quote_parameters(http_query) + ' , dictionaries query: ' + httprequest_dictionary['query']   
    7372       
    7473    finally:  
  • seattle/trunk/seattlelib/tests/registerhttpcallback_tests/ut_registerhttpcallback_exception.py

    r3253 r3313  
    1111 
    1212 
    13 def test_callbackfunc_error(httprequest_dictionary): 
     13def test_callbackfunc_error(httprequest_dictionary, http_query, http_post): 
    1414  # server that raises an exception     
    1515  raise HttpError404('The file no longer exists') 
  • seattle/trunk/seattlelib/tests/registerhttpcallback_tests/ut_registerhttpcallback_redirect.py

    r3253 r3313  
    1010 
    1111 
    12 def test_redirect(httprequest_dictionary): 
     12def test_redirect(httprequest_dictionary, http_query, http_post): 
    1313  # server that redirects to a different server(http://127.0.0.2:12345)    
    1414  raise HttpError302('http://127.0.0.2:12345') 
    1515 
    16 def test_redirected(httprequest_dictionary): 
     16def test_redirected(httprequest_dictionary, http_query, http_post): 
    1717 # normal server that sends a content   
    18  return mycontext['redirect_content']    
     18 return [mycontext['redirect_content'], None]   
    1919 
    2020