<s> import unittest <EOL> from libsaas . executors import test_executor <EOL> from libsaas . services import bitly <EOL> class BitlyTestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . executor = test_executor . use ( ) <EOL> self . executor . set_response ( b'<STR_LIT:{}>' , <NUM_LIT:200> , { } ) <EOL> self . service = bitly . Bitly ( '<STR_LIT>' ) <EOL> def expect ( self , method = None , uri = None , params = { } ) : <EOL> if method : <EOL> self . assertEqual ( method , self . executor . request . method ) <EOL> if uri : <EOL> self . assertEqual ( <EOL> self . executor . request . uri , <EOL> '<STR_LIT>' + uri ) <EOL> if params : <EOL> params . update ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> self . assertEqual ( self . executor . request . params , params ) <EOL> def test_users ( self ) : <EOL> self . service . user ( ) . info ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . user ( ) . info ( login = '<STR_LIT>' ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> self . service . user ( ) . info ( login = '<STR_LIT>' , full_name = '<STR_LIT:foo>' ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:foo>' <EOL> } ) <EOL> self . service . user ( ) . link_history ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . user ( ) . link_history ( link = '<STR_LIT>' ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } ) <EOL> self . service . user ( ) . link_history ( expand_client_id = True ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { <EOL> '<STR_LIT>' : '<STR_LIT:true>' <EOL> } ) <EOL> self . service . user ( ) . network_history ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . user ( ) . network_history ( expand_client_id = True ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { <EOL> '<STR_LIT>' : '<STR_LIT:true>' <EOL> } ) <EOL> self . service . user ( ) . tracking_domain_list ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> for method_name in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> method = getattr ( self . service . user ( ) , method_name ) <EOL> method ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' % method_name , { } ) <EOL> method ( timezone = '<STR_LIT>' ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' % method_name , { <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } ) <EOL> method ( timezone = '<STR_LIT>' , unit = '<STR_LIT>' ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' % method_name , { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } ) <EOL> method ( timezone = '<STR_LIT>' , unit = '<STR_LIT>' ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' % method_name , { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } ) <EOL> def test_links ( self ) : <EOL> for method_name in [ '<STR_LIT:info>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT:location>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> method = getattr ( <EOL> self . service . link ( link = '<STR_LIT>' ) , method_name ) <EOL> method ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' % method_name , { <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } ) <EOL> self . service . link ( link = '<STR_LIT>' ) . content ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } ) <EOL> self . service . link ( link = '<STR_LIT>' ) . content ( content_type = '<STR_LIT:text>' ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { <EOL> '<STR_LIT>' : '<STR_LIT:text>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } ) <EOL> for method_name in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] : <EOL> method = getattr ( <EOL> self . service . link ( link = '<STR_LIT>' ) , method_name ) <EOL> method ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' % method_name , { <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } ) <EOL> method ( timezone = '<STR_LIT>' ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' % method_name , { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } ) <EOL> method ( timezone = '<STR_LIT>' , unit = '<STR_LIT>' ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' % method_name , { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } ) <EOL> method ( timezone = '<STR_LIT>' , unit = '<STR_LIT>' ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' % method_name , { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } ) <EOL> def test_highvalue ( self ) : <EOL> self . service . highvalue ( ) . get ( limit = <NUM_LIT:10> ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { '<STR_LIT>' : <NUM_LIT:10> } ) <EOL> def test_search ( self ) : <EOL> self . service . search ( ) . get ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . search ( ) . get ( limit = <NUM_LIT:10> ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { '<STR_LIT>' : <NUM_LIT:10> } ) <EOL> def test_realtime ( self ) : <EOL> self . service . realtime ( ) . bursting_phrases ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . realtime ( ) . bursting_phrases ( ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { } ) <EOL> self . service . realtime ( ) . clickrate ( phrase = '<STR_LIT:foo>' ) <EOL> self . expect ( '<STR_LIT:GET>' , '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT:foo>' } ) </s>
