]> jfr.im git - z_archive/twitter.git/commitdiff
Extend API so I can use underscore to insert an integer value into URL.
authormiv <redacted>
Wed, 5 Oct 2011 20:02:25 +0000 (22:02 +0200)
committermiv <redacted>
Wed, 5 Oct 2011 20:02:25 +0000 (22:02 +0200)
tests/test_sanity.py
twitter/api.py

index 1adb04a652148c89e45e5f85b8d5253d9e75ddaf..fe3a1974bde1c48afdaf86d974124129990ec574 100644 (file)
@@ -56,3 +56,16 @@ def test_search():
     t_search = Twitter(domain='search.twitter.com')
     results = t_search.search(q='foo')
     assert results
+
+
+def test_get_trends():
+    # This is one method of inserting parameters, using named
+    # underscore params.
+    world_trends = twitter.trends._woeid(_woeid=1)
+    assert world_trends
+
+
+def test_get_trends_2():
+    # This is a nicer variation of the same call as above.
+    world_trends = twitter.trends._(1)
+    assert world_trends
index 4520e354bc48fd564666b77e1f580363abe75fef..6cfc650498e8f0179ff3f1726a359d6497a0c17c 100644 (file)
@@ -104,10 +104,16 @@ class TwitterCall(object):
         try:
             return object.__getattr__(self, k)
         except AttributeError:
-            return self.callable_cls(
-                auth=self.auth, format=self.format, domain=self.domain,
-                callable_cls=self.callable_cls, uriparts=self.uriparts + (k,),
-                secure=self.secure)
+            def extend_call(arg):
+                return self.callable_cls(
+                    auth=self.auth, format=self.format, domain=self.domain,
+                    callable_cls=self.callable_cls, uriparts=self.uriparts \
+                        + (arg,),
+                    secure=self.secure)
+            if k == "_":
+                return extend_call
+            else:
+                return extend_call(k)
 
     def __call__(self, **kwargs):
         # Build the uri.