def get_token(): "wrapper for cache twitter auth-token" key = 'tw-token' tk = cache.get(key) if not tk: tk = tw_api.get_authtoken() cache.set(key, tk, timeout=10*60) return tk
def test_tw_api(self): # auth token = tw_api.get_authtoken() self.assertTrue(token) print token # top-tweets res = tw_api.get_toptweets(token, "New Spiderman") self.assertEqual(type(res), tuple) self.assertEqual(res[0], 200) self.assertTrue(isinstance(res[1], list))