#NEWLINE# def test_TSO_geo( self ) : #NEWLINE# #INDENT# ' Tests TwitterSearchOrder.set_geocode() ' #NEWLINE# tso = self . getCopy ( ) #NEWLINE# cor_geo = [ 0.0 , ( - 12.331 ) , 99.019 , 12.33 ] #NEWLINE# for lat in cor_geo : #NEWLINE# #INDENT# is_km = bool ( random . getrandbits ( 1 ) ) #NEWLINE# lon = random . choice ( lon ) #NEWLINE# radius = self . generateInt ( 1 , 100 ) #NEWLINE# tso . set_geocode ( lat , lon , radius , imperial_metric = is_km ) #NEWLINE# unit = ( 'km' if is_km else 'mi' ) #NEWLINE# cor = ( '%s&geocode=%s,%s,%s%s' % ( self . __tso . create_search_url ( ) , lat , lon , radius , unit ) ) #NEWLINE# self . assertEqualQuery ( tso . create_search_url ( ) , cor ) #NEWLINE# #UNINDENT# wrong_values = [ ( - 1 ) , 1.0 , 101 , '' , [ ] , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ] #NEWLINE# for value in wrong_values : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# radius = self . generateInt ( ( - 200 ) , ( - 1 ) ) #NEWLINE# unit = bool ( random . getrandbits ( 1 ) ) #NEWLINE# tso . set_geocode ( value , value , radius , imperial_metric = unit ) #NEWLINE# self . assertTrue ( False , ( 'Not raising exception for lat %s, lon %s, radius %s and metric %s' % ( value , value , radius , unit ) ) ) #NEWLINE# #UNINDENT# except TwitterSearchException as e : #NEWLINE# #INDENT# self . assertTrue ( ( ( e . code == 1004 ) or ( e . code == 1005 ) ) , 'Wrong exception code' ) #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# tso . set_geocode ( 2.0 , 1.0 , 10 , imperial_metric = 'foo' ) #NEWLINE# #UNINDENT# except TwitterSearchException as e : #NEWLINE# #INDENT# self . assertEqual ( e . code , 1005 , 'Wrong exception code' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# tso . set_geocode ( 'foo' , 'bar' , 10 ) #NEWLINE# #UNINDENT# except TwitterSearchException as e : #NEWLINE# #INDENT# self . assertEqual ( e . code , 1004 , 'Wrong exception code' )