Merge lp:~ken-vandine/friends/identica_favorites into lp:friends

Proposed by Ken VanDine
Status: Merged
Approved by: Robert Bruce Park
Approved revision: 176
Merged at revision: 176
Proposed branch: lp:~ken-vandine/friends/identica_favorites
Merge into: lp:friends
Diff against target: 130 lines (+38/-21)
4 files modified
friends/protocols/identica.py (+3/-8)
friends/protocols/twitter.py (+5/-2)
friends/tests/test_dispatcher.py (+4/-3)
friends/tests/test_identica.py (+26/-8)
To merge this branch: bzr merge lp:~ken-vandine/friends/identica_favorites
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Robert Bruce Park Approve
Review via email: mp+156733@code.launchpad.net

Commit message

Fixed endpoint for favorites on identica

Description of the change

Fixed endpoint for favorites on identica, no longer raising NotImplemented.

To post a comment you must log in.
Revision history for this message
Robert Bruce Park (robru) wrote :

Weird, how did you figure this out? Did Identica update their API docs? Because I'm pretty sure at the time that I wrote that NotImplemented code for Identica, their API docs claimed that their favorites API was identical to Twitter's, but it just kept giving me 404s.

anywas, looks good, tests are passing.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:176
http://jenkins.qa.ubuntu.com/job/friends-ci/17/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/friends-raring-amd64-ci/17

Click here to trigger a rebuild:
http://s-jenkins:8080/job/friends-ci/17/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'friends/protocols/identica.py'
2--- friends/protocols/identica.py 2013-02-05 01:11:35 +0000
3+++ friends/protocols/identica.py 2013-04-03 03:50:29 +0000
4@@ -36,6 +36,9 @@
5 _search = _api_base.format(endpoint='search')
6 _search_result_key = 'results'
7
8+ _favorite = _api_base.format(endpoint='favorites/create/{}')
9+ _del_favorite = _api_base.format(endpoint='favorites/destroy/{}')
10+
11 _tweet_permalink = 'http://identi.ca/notice/{tweet_id}'
12
13 def _whoami(self, authdata):
14@@ -54,14 +57,6 @@
15 """Identi.ca does not have this feature."""
16 raise NotImplementedError
17
18- def like(self, tweet_id):
19- """I get 404s on this in spite of Identi.ca's claim to support it."""
20- raise NotImplementedError
21-
22- def unlike(self, tweet_id):
23- """I get 404s on this in spite of Identi.ca's claim to support it."""
24- raise NotImplementedError
25-
26 def tag(self, tweet_id):
27 """Searching for hashtags gives non-hashtags in the results.
28
29
30=== modified file 'friends/protocols/twitter.py'
31--- friends/protocols/twitter.py 2013-04-02 21:46:47 +0000
32+++ friends/protocols/twitter.py 2013-04-03 03:50:29 +0000
33@@ -62,6 +62,9 @@
34 _search = _api_base.format(endpoint='search/tweets')
35 _search_result_key = 'statuses'
36
37+ _favorite = _api_base.format(endpoint='favorites/create')
38+ _del_favorite = _api_base.format(endpoint='favorites/destroy')
39+
40 _tweet_permalink = 'https://twitter.com/{user_id}/status/{tweet_id}'
41
42 def __init__(self, account):
43@@ -303,7 +306,7 @@
44 @feature
45 def like(self, message_id):
46 """Announce to the world your undying love for a tweet."""
47- url = self._api_base.format(endpoint='favorites/create')
48+ url = self._favorite.format(message_id)
49 self._get_url(url, dict(id=message_id))
50 self._inc_cell(message_id, 'likes')
51 self._set_cell(message_id, 'liked', True)
52@@ -313,7 +316,7 @@
53 @feature
54 def unlike(self, message_id):
55 """Renounce your undying love for a tweet."""
56- url = self._api_base.format(endpoint='favorites/destroy')
57+ url = self._del_favorite.format(message_id)
58 self._get_url(url, dict(id=message_id))
59 self._dec_cell(message_id, 'likes')
60 self._set_cell(message_id, 'liked', False)
61
62=== modified file 'friends/tests/test_dispatcher.py'
63--- friends/tests/test_dispatcher.py 2013-03-20 01:19:39 +0000
64+++ friends/tests/test_dispatcher.py 2013-04-03 03:50:29 +0000
65@@ -198,9 +198,10 @@
66 'retweet', 'search', 'send', 'send_private',
67 'send_thread', 'tag', 'unfollow', 'unlike', 'user'])
68 self.assertEqual(json.loads(self.dispatcher.GetFeatures('identica')),
69- ['contacts', 'delete', 'follow', 'home', 'mentions',
70- 'private', 'receive', 'retweet', 'search', 'send',
71- 'send_private', 'send_thread', 'unfollow', 'user'])
72+ ['contacts', 'delete', 'follow', 'home', 'like',
73+ 'mentions', 'private', 'receive', 'retweet',
74+ 'search', 'send', 'send_private', 'send_thread',
75+ 'unfollow', 'unlike', 'user'])
76 self.assertEqual(json.loads(self.dispatcher.GetFeatures('flickr')),
77 ['receive', 'upload'])
78 self.assertEqual(json.loads(self.dispatcher.GetFeatures('foursquare')),
79
80=== modified file 'friends/tests/test_identica.py'
81--- friends/tests/test_identica.py 2013-04-02 21:41:53 +0000
82+++ friends/tests/test_identica.py 2013-04-03 03:50:29 +0000
83@@ -197,14 +197,6 @@
84 'http://identi.ca/api/friendships/create.json',
85 dict(screen_name='pumpichank', follow='true'))
86
87- def test_like(self):
88- self.protocol._get_url = mock.Mock()
89- self.assertRaises(NotImplementedError, self.protocol.like, '1234')
90-
91- def test_unlike(self):
92- self.protocol._get_url = mock.Mock()
93- self.assertRaises(NotImplementedError, self.protocol.unlike, '1234')
94-
95 def test_tag(self):
96 self.protocol._get_url = mock.Mock(
97 return_value=dict(statuses=['tweet']))
98@@ -240,6 +232,32 @@
99 )
100 self.assertEqual(userdata, {"name":"Alice"})
101
102+ def test_like(self):
103+ get_url = self.protocol._get_url = mock.Mock()
104+ inc_cell = self.protocol._inc_cell = mock.Mock()
105+ set_cell = self.protocol._set_cell = mock.Mock()
106+
107+ self.assertEqual(self.protocol.like('1234'), '1234')
108+
109+ inc_cell.assert_called_once_with('1234', 'likes')
110+ set_cell.assert_called_once_with('1234', 'liked', True)
111+ get_url.assert_called_with(
112+ 'http://identi.ca/api/favorites/create/1234.json',
113+ dict(id='1234'))
114+
115+ def test_unlike(self):
116+ get_url = self.protocol._get_url = mock.Mock()
117+ dec_cell = self.protocol._dec_cell = mock.Mock()
118+ set_cell = self.protocol._set_cell = mock.Mock()
119+
120+ self.assertEqual(self.protocol.unlike('1234'), '1234')
121+
122+ dec_cell.assert_called_once_with('1234', 'likes')
123+ set_cell.assert_called_once_with('1234', 'liked', False)
124+ get_url.assert_called_with(
125+ 'http://identi.ca/api/favorites/destroy/1234.json',
126+ dict(id='1234'))
127+
128 def test_create_contact(self, *mocks):
129 # Receive the users friends.
130 bare_contact = {'name': 'Alice Bob',

Subscribers

People subscribed via source and target branches

to all changes: