def test_query_merge(self): google = doze.url("http://google.com/?x=doze") google = google("search/?q=query") self.assertEqual("http://google.com/search/?x=doze&q=query", str(google)) google = doze.url("http://google.com/?q=doze") google = google("search/?q=query") self.assertEqual("http://google.com/search/?q=query", str(google))
def test_simple(self): user_lookup = doze.url("http://api.twitter.com/1/", "users", "lookup.json", screen_name="ericmoritz") self.assertEqual("http://api.twitter.com/1/users/lookup.json?screen_name=ericmoritz", str(user_lookup))
def test_simple(self): user_lookup = doze.url("http://api.twitter.com/1/", "users", "lookup.json", screen_name="ericmoritz") self.assertEqual( "http://api.twitter.com/1/users/lookup.json?screen_name=ericmoritz", str(user_lookup))
def test(self): twitter = doze.url("http://api.twitter.com/1/") home_timeline = twitter.statuses("home_timeline.json") user_lookup = twitter.users("lookup.json") self.assertEqual("http://api.twitter.com/1/statuses/home_timeline.json", str(home_timeline)) self.assertEqual("http://api.twitter.com/1/users/lookup.json?screen_name=ericmoritz", str(user_lookup(screen_name="ericmoritz")))
def test(self): twitter = doze.url("http://api.twitter.com/1/") home_timeline = twitter.statuses("home_timeline.json") user_lookup = twitter.users("lookup.json") self.assertEqual( "http://api.twitter.com/1/statuses/home_timeline.json", str(home_timeline)) self.assertEqual( "http://api.twitter.com/1/users/lookup.json?screen_name=ericmoritz", str(user_lookup(screen_name="ericmoritz")))
def test_list_params(self): google = doze.url("http://example.com/") self.assertEqual("http://example.com/?x=1&x=2", str(google(x=[1,2])))
def test_nonstring_bits(self): google = doze.url("http://google.com/") google = google("story", 10) self.assertEqual("http://google.com/story/10?page=1", str(google(page=1)))
def test_dupe_queries(self): google = doze.url("http://google.com/?q=doze") self.assertEqual("http://google.com/?q=Eric+Moritz", str(google(q="Eric Moritz")))
def test_hardcoded_queries(self): google = doze.url("http://google.com/?x=doze") self.assertEqual("http://google.com/?x=doze&q=Eric+Moritz", str(google(q="Eric Moritz")))
from webob import Response import webbrowser requests_cache.install_cache() USERNAME=os.environ['USERNAME'] PLAYLIST=os.environ['PLAYLIST'] CLIENT_ID=os.environ['CLIENT_ID'] CLIENT_SECRET=os.environ['CLIENT_SECRET'] REDIRECT_URI='http://local.ericmoritz.name:8000/' STATE=shelve.open('.state') logging.basicConfig(level=logging.INFO) accounts_service = url('https://accounts.spotify.com') spotify_service = url('https://api.spotify.com/v1') playlist_resource = spotify_service.users(USERNAME).playlists(PLAYLIST).tracks def lines(filenames): return chain.from_iterable( open(fn) for fn in filenames ) def _spotify_get(url, *args, **kwargs): logging.info("Getting {}".format(url)) kwargs['headers'] = dict(auth_headers(), **kwargs.get('headers', {})) return json.loads( requests.get( str(url),
def test_list_params(self): google = doze.url("http://example.com/") self.assertEqual("http://example.com/?x=1&x=2", str(google(x=[1, 2])))