Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix issue #90. Use _id to mean 'id' as a CGI param.

  • Loading branch information...
commit 920528cd24c34f4759113639ae7be42f65c498a5 1 parent 4e7d969
@sixohsix authored
Showing with 16 additions and 14 deletions.
  1. +10 −14 tests/test_sanity.py
  2. +6 −0 twitter/api.py
View
24 tests/test_sanity.py
@@ -13,6 +13,9 @@
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)
+
View
6 twitter/api.py
@@ -155,6 +155,12 @@ def __call__(self, **kwargs):
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'
Please sign in to comment.
Something went wrong with that request. Please try again.