Permalink
Browse files

Merge pull request #179 from vinsonlee/use-oauth-in-tests

Use OAuth for authentication in unit tests.
  • Loading branch information...
2 parents 1b73470 + b7efe93 commit 0d3ea5cddb366db6e7d55dce949a484b6dc4fcab @joshthecoder joshthecoder committed Jul 9, 2012
Showing with 11 additions and 5 deletions.
  1. +11 −5 tests.py
View
@@ -9,16 +9,20 @@
# Must supply twitter account credentials for tests
username = ''
password = ''
-consumer_key = ''
-consumer_secret = ''
+oauth_consumer_key = ''
+oauth_consumer_secret = ''
+oauth_token=''
+oauth_token_secret=''
"""Unit tests"""
class TweepyAPITests(unittest.TestCase):
def setUp(self):
- self.api = API(BasicAuthHandler(username, password))
+ auth = OAuthHandler(oauth_consumer_key, oauth_consumer_secret)
+ auth.set_access_token(oauth_token, oauth_token_secret)
+ self.api = API(auth)
self.api.retry_count = 2
self.api.retry_delay = 5
@@ -276,7 +280,9 @@ def testgeoapis(self):
class TweepyCursorTests(unittest.TestCase):
def setUp(self):
- self.api = API(BasicAuthHandler(username, password))
+ auth = OAuthHandler(oauth_consumer_key, oauth_consumer_secret)
+ auth.set_access_token(oauth_token, oauth_token_secret)
+ self.api = API(auth)
self.api.retry_count = 2
self.api.retry_delay = 5
@@ -311,7 +317,7 @@ def testcursorcursorpages(self):
class TweepyAuthTests(unittest.TestCase):
def testoauth(self):
- auth = OAuthHandler(self.consumer_key, self.consumer_secret)
+ auth = OAuthHandler(oauth_consumer_key, oauth_consumer_secret)
# test getting access token
auth_url = auth.get_authorization_url()

0 comments on commit 0d3ea5c

Please sign in to comment.