From 5be123101fc5f8959bb5bed64095ce45f8828b38 Mon Sep 17 00:00:00 2001 From: Joshua Roesslein Date: Sun, 20 Jan 2013 14:18:51 -0800 Subject: [PATCH] Fix create/update/destroy lists for v1.1. --- tests.py | 12 ++++++++---- tweepy/api.py | 44 +++++++++++++++++++++----------------------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/tests.py b/tests.py index 7fa0d35..407a395 100644 --- a/tests.py +++ b/tests.py @@ -244,10 +244,14 @@ class TweepyAPITests(unittest.TestCase): self.api.blocks_ids() def testcreateupdatedestroylist(self): - self.api.create_list('tweeps') - # XXX: right now twitter throws a 500 here, issue is being looked into by twitter. - #self.api.update_list('tweeps', mode='private') - self.api.destroy_list('tweeps') + params = { + 'owner_screen_name': username, + 'slug': 'tweeps' + } + self.api.create_list(name=params['slug'], **params) + l = self.api.update_list(description='updated!', **params) + self.assertEqual(l.description, 'updated!') + self.api.destroy_list(**params) def testlists(self): self.api.lists() diff --git a/tweepy/api.py b/tweepy/api.py index aa232c7..b553aa0 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -533,31 +533,29 @@ class API(object): return False return True - def create_list(self, *args, **kargs): - return bind_api( - path = '/%s/lists.json' % self.auth.get_username(), - method = 'POST', - payload_type = 'list', - allowed_param = ['name', 'mode', 'description'], - require_auth = True - )(self, *args, **kargs) + create_list = bind_api( + path = '/lists/create.json', + method = 'POST', + payload_type = 'list', + allowed_param = ['name', 'mode', 'description'], + require_auth = True + ) - def destroy_list(self, slug): - return bind_api( - path = '/%s/lists/%s.json' % (self.auth.get_username(), slug), - method = 'DELETE', - payload_type = 'list', - require_auth = True - )(self) + destroy_list = bind_api( + path = '/lists/destroy.json', + method = 'POST', + payload_type = 'list', + allowed_param = ['owner_screen_name', 'owner_id', 'list_id', 'slug'], + require_auth = True + ) - def update_list(self, slug, *args, **kargs): - return bind_api( - path = '/%s/lists/%s.json' % (self.auth.get_username(), slug), - method = 'POST', - payload_type = 'list', - allowed_param = ['name', 'mode', 'description'], - require_auth = True - )(self, *args, **kargs) + update_list = bind_api( + path = '/lists/update.json', + method = 'POST', + payload_type = 'list', + allowed_param = ['list_id', 'slug', 'name', 'mode', 'description', 'owner_screen_name', 'owner_id'], + require_auth = True + ) lists = bind_api( path = '/{user}/lists.json', -- 2.25.1