3
3
from time import sleep
4
4
import os
5
5
6
- from tweepy import (API , BasicAuthHandler , OAuthHandler , Friendship , Cursor ,
6
+ from nose import SkipTest
7
+
8
+ from tweepy import (API , OAuthHandler , Friendship , Cursor ,
7
9
MemoryCache , FileCache )
8
10
9
11
"""Configurations"""
@@ -43,31 +45,19 @@ def setUp(self):
43
45
def testhometimeline (self ):
44
46
self .api .home_timeline ()
45
47
46
- def testfriendstimeline (self ):
47
- self .api .friends_timeline ()
48
-
49
48
def testusertimeline (self ):
50
49
self .api .user_timeline ()
51
50
self .api .user_timeline ('twitter' )
52
51
53
- def testmentions (self ):
54
- self .api .mentions ()
55
-
56
- def testretweetedbyme (self ):
57
- self .api .retweeted_by_me ()
58
-
59
- def testretweetedbyuser (self ):
60
- self .api .retweeted_by_user ('twitter' )
61
-
62
- def testretweetedtome (self ):
63
- self .api .retweeted_to_me ()
52
+ def testmentionstimeline (self ):
53
+ self .api .mentions_timeline ()
64
54
65
55
def testretweetsofme (self ):
66
56
self .api .retweets_of_me ()
67
57
68
58
def testretweet (self ):
69
- s = self . api . retweet ( test_tweet_id )
70
- s . destroy ()
59
+ # TODO(josh): Need a way to get random tweets to retweet.
60
+ raise SkipTest ()
71
61
72
62
def testretweets (self ):
73
63
self .api .retweets (test_tweet_id )
@@ -112,12 +102,6 @@ def testme(self):
112
102
me = self .api .me ()
113
103
self .assertEqual (me .screen_name , username )
114
104
115
- def testfriends (self ):
116
- self .api .friends ()
117
-
118
- def testfollowers (self ):
119
- self .api .followers ()
120
-
121
105
def testdirectmessages (self ):
122
106
self .api .direct_messages ()
123
107
@@ -193,11 +177,11 @@ def testupdateprofilecolors(self):
193
177
original .profile_sidebar_border_color
194
178
)
195
179
196
- self .assertEqual (updated .profile_background_color , '000 ' )
197
- self .assertEqual (updated .profile_text_color , '000 ' )
198
- self .assertEqual (updated .profile_link_color , '000 ' )
199
- self .assertEqual (updated .profile_sidebar_fill_color , '000 ' )
200
- self .assertEqual (updated .profile_sidebar_border_color , '000 ' )
180
+ self .assertEqual (updated .profile_background_color , '000000 ' )
181
+ self .assertEqual (updated .profile_text_color , '000000 ' )
182
+ self .assertEqual (updated .profile_link_color , '000000 ' )
183
+ self .assertEqual (updated .profile_sidebar_fill_color , '000000 ' )
184
+ self .assertEqual (updated .profile_sidebar_border_color , '000000 ' )
201
185
202
186
"""
203
187
def testupateprofileimage(self):
@@ -232,15 +216,9 @@ def testcreatedestroyfavorite(self):
232
216
self .api .create_favorite (4901062372 )
233
217
self .api .destroy_favorite (4901062372 )
234
218
235
- def testenabledisablenotifications (self ):
236
- self .api .enable_notifications ('twitter' )
237
- self .api .disable_notifications ('twitter' )
238
-
239
219
def testcreatedestroyblock (self ):
240
220
self .api .create_block ('twitter' )
241
- self .assertEqual (self .api .exists_block ('twitter' ), True )
242
221
self .api .destroy_block ('twitter' )
243
- self .assertEqual (self .api .exists_block ('twitter' ), False )
244
222
self .api .create_friendship ('twitter' ) # restore
245
223
246
224
def testblocks (self ):
@@ -250,13 +228,17 @@ def testblocksids(self):
250
228
self .api .blocks_ids ()
251
229
252
230
def testcreateupdatedestroylist (self ):
253
- self .api .create_list ('tweeps' )
254
- # XXX: right now twitter throws a 500 here, issue is being looked into by twitter.
255
- #self.api.update_list('tweeps', mode='private')
256
- self .api .destroy_list ('tweeps' )
231
+ params = {
232
+ 'owner_screen_name' : username ,
233
+ 'slug' : 'tweeps'
234
+ }
235
+ l = self .api .create_list (name = params ['slug' ], ** params )
236
+ l = self .api .update_list (list_id = l .id , description = 'updated!' )
237
+ self .assertEqual (l .description , 'updated!' )
238
+ self .api .destroy_list (list_id = l .id )
257
239
258
- def testlists (self ):
259
- self .api .lists ()
240
+ def testlistsall (self ):
241
+ self .api .lists_all ()
260
242
261
243
def testlistsmemberships (self ):
262
244
self .api .lists_memberships ()
@@ -268,30 +250,40 @@ def testlisttimeline(self):
268
250
self .api .list_timeline ('applepie' , 'stars' )
269
251
270
252
def testgetlist (self ):
271
- self .api .get_list ('applepie' , 'stars' )
253
+ self .api .get_list (owner_screen_name = 'applepie' , slug = 'stars' )
272
254
273
255
def testaddremovelistmember (self ):
274
- uid = self .api .get_user ('twitter' ).id
275
- self .api .add_list_member ('test' , uid )
276
- self .api .remove_list_member ('test' , uid )
256
+ params = {
257
+ 'slug' : 'test' ,
258
+ 'owner_screen_name' : username ,
259
+ 'screen_name' : 'twitter'
260
+ }
261
+
262
+ def assert_list (l ):
263
+ self .assertEqual (l .name , params ['slug' ])
264
+
265
+ assert_list (self .api .add_list_member (** params ))
266
+ assert_list (self .api .remove_list_member (** params ))
277
267
278
268
def testlistmembers (self ):
279
269
self .api .list_members ('applepie' , 'stars' )
280
270
281
- def testislistmember (self ):
282
- uid = self .api .get_user ('applepie' ).id
283
- self .api .is_list_member ('applepie' , 'stars' , uid )
271
+ def testshowlistmember (self ):
272
+ self .assertTrue (self .api .show_list_member (owner_screen_name = 'applepie' , slug = 'stars' , screen_name = 'NathanFillion' ))
284
273
285
274
def testsubscribeunsubscribelist (self ):
286
- self .api .subscribe_list ('applepie' , 'stars' )
287
- self .api .unsubscribe_list ('applepie' , 'stars' )
275
+ params = {
276
+ 'owner_screen_name' : 'applepie' ,
277
+ 'slug' : 'stars'
278
+ }
279
+ self .api .subscribe_list (** params )
280
+ self .api .unsubscribe_list (** params )
288
281
289
282
def testlistsubscribers (self ):
290
283
self .api .list_subscribers ('applepie' , 'stars' )
291
284
292
- def testissubscribedlist (self ):
293
- uid = self .api .get_user ('applepie' ).id
294
- self .api .is_subscribed_list ('applepie' , 'stars' , uid )
285
+ def testshowlistsubscriber (self ):
286
+ self .assertTrue (self .api .show_list_subscriber ('applepie' , 'stars' , username ))
295
287
296
288
def testsavedsearches (self ):
297
289
s = self .api .create_saved_search ('test' )
@@ -302,10 +294,6 @@ def testsavedsearches(self):
302
294
def testsearch (self ):
303
295
self .api .search ('tweepy' )
304
296
305
- def testtrends (self ):
306
- self .api .trends_daily ()
307
- self .api .trends_weekly ()
308
-
309
297
def testgeoapis (self ):
310
298
def place_name_in_list (place_name , place_list ):
311
299
"""Return True if a given place_name is in place_list."""
@@ -316,8 +304,6 @@ def place_name_in_list(place_name, place_list):
316
304
self .assertEqual (twitter_hq [0 ].id , '3bdf30ed8b201f31' )
317
305
# Test various API functions using Austin, TX, USA
318
306
self .assertEqual (self .api .geo_id (id = 'c3f37afa9efcf94b' ).full_name , 'Austin, TX' )
319
- self .assertTrue (place_name_in_list ('Austin, TX' ,
320
- self .api .nearby_places (lat = 30.267370168467806 , long = - 97.74261474609375 ))) # Austin, TX, USA
321
307
self .assertTrue (place_name_in_list ('Austin, TX' ,
322
308
self .api .reverse_geocode (lat = 30.267370168467806 , long = - 97.74261474609375 ))) # Austin, TX, USA
323
309
@@ -345,17 +331,17 @@ def testpagecursorpages(self):
345
331
self .assert_ (len (pages ) == 5 )
346
332
347
333
def testcursorcursoritems (self ):
348
- items = list (Cursor (self .api .friends ).items ())
334
+ items = list (Cursor (self .api .friends_ids ).items ())
349
335
self .assert_ (len (items ) > 0 )
350
336
351
- items = list (Cursor (self .api .followers , 'twitter' ).items (30 ))
337
+ items = list (Cursor (self .api .followers_ids , 'twitter' ).items (30 ))
352
338
self .assert_ (len (items ) == 30 )
353
339
354
340
def testcursorcursorpages (self ):
355
- pages = list (Cursor (self .api .friends ).pages ())
341
+ pages = list (Cursor (self .api .friends_ids ).pages ())
356
342
self .assert_ (len (pages ) > 0 )
357
343
358
- pages = list (Cursor (self .api .followers , 'twitter' ).pages (5 ))
344
+ pages = list (Cursor (self .api .followers_ids , 'twitter' ).pages (5 ))
359
345
self .assert_ (len (pages ) == 5 )
360
346
361
347
class TweepyAuthTests (unittest .TestCase ):
0 commit comments