class TweepyAPITests(unittest.TestCase):
# Must supply twitter account credentials for tests
- username = 'jitterapp'
- password = 'omega123'
+ username = 'tweebly'
+ password = 'omega1987twitter'
def setUp(self):
- self.api = API(self.username, self.password)
-
- def testsetcredentials(self):
- testapi = API()
- testapi.set_credentials('test', 'donttellanyone')
- self.assert_(testapi._b64up)
- self.assertEqual(testapi.username, 'test')
+ self.api = API(BasicAuthHandler(self.username, self.password), self.username)
def testpublictimeline(self):
s = self.api.public_timeline()
"""Twitter API"""
class API(object):
- def __init__(self, auth_handler=None, host='twitter.com', cache=None,
+ def __init__(self, auth_handler=None, username=None, host='twitter.com', cache=None,
secure=False, classes={'user': User, 'status': Status,
'direct_message': DirectMessage, 'friendship': Friendship,
'saved_search': SavedSearch, 'search_result': SearchResult}):
self.auth_handler = auth_handler
+ self.username = username
self.host = host
self.cache = cache
self.secure = secure