]> jfr.im git - z_archive/twitter.git/blobdiff - tests/test_sanity.py
Fix search test to use 1.1 API.
[z_archive/twitter.git] / tests / test_sanity.py
index 941d2870767551e5dad351508888ee5d1da048ee..cb9bf177463f03f8ef01fd1e04c72dab6b9683c7 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()
@@ -17,6 +17,7 @@ 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"
@@ -46,8 +47,7 @@ def test_API_set_unicode_tweet():
 
 
 def test_search():
-    t_search = Twitter(domain='search.twitter.com')
-    results = t_search.search(q='foo')
+    results = twitter11.search.tweets(q='foo')
     assert results
 
 
@@ -68,3 +68,11 @@ 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