]> jfr.im git - z_archive/twitter.git/commitdiff
Fix issue #90. Use _id to mean 'id' as a CGI param.
authorMike Verdone <redacted>
Thu, 11 Oct 2012 20:19:24 +0000 (22:19 +0200)
committerMike Verdone <redacted>
Thu, 11 Oct 2012 20:19:24 +0000 (22:19 +0200)
tests/test_sanity.py
twitter/api.py

index 0f2389c5456a1738c4378d8a9f40659c75622e18..941d2870767551e5dad351508888ee5d1da048ee 100644 (file)
@@ -13,6 +13,9 @@ 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')
 
 
@@ -22,12 +25,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 +37,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 +45,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 +62,9 @@ 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)
+
index 8c7b08a325d0df7a16974c198e9572330037d99d..7d5537782a908132044432f0a60c0d696500193c 100644 (file)
@@ -155,6 +155,12 @@ class TwitterCall(object):
         if id:
             uri += "/%s" %(id)
 
+        # If an _id kwarg is present, this is treated as id as a CGI
+        # param.
+        _id = kwargs.pop('_id', None)
+        if _id:
+            kwargs['id'] = _id
+
         secure_str = ''
         if self.secure:
             secure_str = 's'