]> jfr.im git - z_archive/twitter.git/blobdiff - tests/test_sanity.py
Merge pull request #131 from pykler/master
[z_archive/twitter.git] / tests / test_sanity.py
index 0f2389c5456a1738c4378d8a9f40659c75622e18..cf0833951dca306400c302037fcb0b1e60e86919 100644 (file)
@@ -3,7 +3,7 @@
 from random import choice
 import time
 
-from twitter import Twitter, NoAuth, OAuth, read_token_file
+from twitter import Twitter, NoAuth, OAuth, read_token_file, TwitterHTTPError
 from twitter.cmdline import CONSUMER_KEY, CONSUMER_SECRET
 
 noauth = NoAuth()
@@ -13,7 +13,11 @@ oauth = OAuth(*read_token_file('tests/oauth_creds')
 twitter = Twitter(domain='api.twitter.com',
                   auth=oauth,
                   api_version='1')
+twitter11 = Twitter(domain='api.twitter.com',
+                    auth=oauth,
+                    api_version='1.1')
 twitter_na = Twitter(domain='api.twitter.com', auth=noauth, api_version='1')
+twitter11_na = Twitter(domain='api.twitter.com', auth=noauth, api_version='1.1')
 
 
 AZaz = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"
@@ -22,12 +26,6 @@ def get_random_str():
     return ''.join(choice(AZaz) for _ in range(10))
 
 
-def test_API_get_some_public_tweets():
-    updates = twitter_na.statuses.public_timeline()
-    assert updates
-    assert updates[0]['created_at']
-
-
 def test_API_set_tweet():
     random_tweet = "A random tweet " + get_random_str()
     twitter.statuses.update(status=random_tweet)
@@ -40,7 +38,7 @@ def test_API_set_tweet():
 
 
 def test_API_set_unicode_tweet():
-    random_tweet = u"A random tweet with unicode ⇰ÐÀ " + get_random_str()
+    random_tweet = u"A random tweet with unicode üøπ" + get_random_str()
     twitter.statuses.update(status=random_tweet)
 
     recent = twitter.statuses.user_timeline()
@@ -48,13 +46,6 @@ def test_API_set_unicode_tweet():
     assert random_tweet == recent[0]['text']
 
 
-def test_API_friendship_exists():
-    assert True == twitter.friendships.exists(
-        user_a='ptttest0001', user_b='sixohsix')
-    assert False == twitter.friendships.exists(
-        user_a='gruber', user_b='ptttest0001')
-
-
 def test_search():
     t_search = Twitter(domain='search.twitter.com')
     results = t_search.search(q='foo')
@@ -72,3 +63,18 @@ def test_get_trends_2():
     # This is a nicer variation of the same call as above.
     world_trends = twitter.trends._(1)
     assert world_trends
+
+
+def test_get_trends_3():
+    # Of course they broke it all again in 1.1...
+    assert twitter11.trends.place(_id=1)
+
+def test_TwitterHTTPError_raised_for_invalid_oauth():
+    test_passed = False
+    try:
+        twitter11_na.statuses.mentions_timeline()
+    except TwitterHTTPError:
+        # this is the error we are looking for :)
+        test_passed = True
+    assert test_passed
+