Commit 9bcc4a18 authored by Joshua Roesslein's avatar Joshua Roesslein
Browse files

Fix up tests to get them passing.

Removed a few deprecated tests and added
environment variable lookup for getting oAuth credentials.
parent e323190a
......@@ -8,12 +8,11 @@ from tweepy import (API, BasicAuthHandler, OAuthHandler, Friendship, Cursor,
"""Configurations"""
# Must supply twitter account credentials for tests
username = ''
password = ''
oauth_consumer_key = ''
oauth_consumer_secret = ''
oauth_token=''
oauth_token_secret=''
username = os.environ.get('TWITTER_USERNAME', '')
oauth_consumer_key = os.environ.get('CONSUMER_KEY', '')
oauth_consumer_secret = os.environ.get('CONSUMER_SECRET', '')
oauth_token = os.environ.get('ACCESS_KEY', '')
oauth_token_secret = os.environ.get('ACCESS_SECRET', '')
"""Unit tests"""
......@@ -115,11 +114,9 @@ class TweepyAPITests(unittest.TestCase):
def testcreatedestroyfriendship(self):
enemy = self.api.destroy_friendship('twitter')
self.assertEqual(enemy.screen_name, 'twitter')
self.assertFalse(self.api.exists_friendship(username, 'twitter'))
friend = self.api.create_friendship('twitter')
self.assertEqual(friend.screen_name, 'twitter')
self.assertTrue(self.api.exists_friendship(username, 'twitter'))
def testshowfriendship(self):
source, target = self.api.show_friendship(target_screen_name='twtiter')
......@@ -143,15 +140,14 @@ class TweepyAPITests(unittest.TestCase):
me = self.api.verify_credentials(skip_status=True)
self.assertFalse(hasattr(me, 'status'))
api = API(BasicAuthHandler('bad', 'password'))
self.assertEqual(api.verify_credentials(), False)
def testratelimitstatus(self):
self.api.rate_limit_status()
""" TODO(josh): Remove once this deprecated API is gone.
def testsetdeliverydevice(self):
self.api.set_delivery_device('im')
self.api.set_delivery_device('none')
"""
def testupdateprofilecolors(self):
original = self.api.me()
......@@ -276,7 +272,6 @@ class TweepyAPITests(unittest.TestCase):
self.api.search('tweepy')
def testtrends(self):
self.api.trends()
self.api.trends_current()
self.api.trends_daily()
self.api.trends_weekly()
......@@ -341,14 +336,6 @@ class TweepyAuthTests(unittest.TestCase):
s = api.update_status('test %i' % random.randint(0, 1000))
api.destroy_status(s.id)
def testbasicauth(self):
auth = BasicAuthHandler(username, password)
# test accessing twitter API
api = API(auth)
s = api.update_status('test %i' % random.randint(1, 1000))
api.destroy_status(s.id)
class TweepyCacheTests(unittest.TestCase):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment