Merge lp:~robru/friends/facebook-stories into lp:~super-friends/friends/raring

Proposed by Robert Bruce Park
Status: Merged
Approved by: Ken VanDine
Approved revision: 176
Merged at revision: 176
Proposed branch: lp:~robru/friends/facebook-stories
Merge into: lp:~super-friends/friends/raring
Diff against target: 189 lines (+128/-7)
3 files modified
friends/protocols/facebook.py (+1/-1)
friends/tests/data/facebook-full.dat (+95/-0)
friends/tests/test_facebook.py (+32/-6)
To merge this branch: bzr merge lp:~robru/friends/facebook-stories
Reviewer Review Type Date Requested Status
Ken VanDine Approve
Review via email: mp+153646@code.launchpad.net

Commit message

Fix the publishing of Facebook Stories (LP: #1155785)

Description of the change

This is a very simple change, but I had to expand the facebook mock data by quite a bit in order to include a test case for this, so I ended up with quite a large diff for an effectively 1-line change.

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

Ken, just be aware that this is going to increase the amount of mock data that appears in the model when you run 'friends-dispatcher --test', so landing this may break your qml-friends tests, depending on how they're written (any tests that check for the number of rows present, or the specific values at specific model indexes will probably need to be updated).

Revision history for this message
Ken VanDine (ken-vandine) wrote :

Looks great!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'friends/protocols/facebook.py'
--- friends/protocols/facebook.py 2013-03-14 02:27:36 +0000
+++ friends/protocols/facebook.py 2013-03-16 01:05:27 +0000
@@ -71,7 +71,7 @@
71 args = dict(71 args = dict(
72 message_id=message_id,72 message_id=message_id,
73 stream=stream,73 stream=stream,
74 message=entry.get('message', ''),74 message=entry.get('message', '') or entry.get('story', ''),
75 icon_uri=entry.get('icon', ''),75 icon_uri=entry.get('icon', ''),
76 link_picture=entry.get('picture', ''),76 link_picture=entry.get('picture', ''),
77 link_name=entry.get('name', ''),77 link_name=entry.get('name', ''),
7878
=== modified file 'friends/tests/data/facebook-full.dat'
--- friends/tests/data/facebook-full.dat 2013-03-14 00:52:23 +0000
+++ friends/tests/data/facebook-full.dat 2013-03-16 01:05:27 +0000
@@ -262,6 +262,101 @@
262 ],262 ],
263 "count": 11263 "count": 11
264 }264 }
265 },
266 {
267 "id": "104443_100085049977",
268 "from": {
269 "name": "Guy Frenchie",
270 "id": "1244414"
271 },
272 "story": "Guy Frenchie did some things with some stuff.",
273 "story_tags": {
274 "0": [
275 {
276 "id": "1244414",
277 "name": "Guy Frenchie",
278 "offset": 0,
279 "length": 16,
280 "type": "user"
281 }
282 ],
283 "26": [
284 {
285 "id": "37067557",
286 "name": "somebody",
287 "offset": 26,
288 "length": 10,
289 "type": "page"
290 }
291 ],
292 "48": [
293 {
294 "id": "50681138",
295 "name": "What do you think about things and stuff?",
296 "offset": 48,
297 "length": 52
298 }
299 ]
300 },
301 "icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yg/r/5PpICR5KcPe.png",
302 "actions": [
303 {
304 "name": "Comment",
305 "link": "https://www.facebook.com/1244414/posts/100085049977"
306 },
307 {
308 "name": "Like",
309 "link": "https://www.facebook.com/1244414/posts/100085049977"
310 }
311 ],
312 "privacy": {
313 "value": ""
314 },
315 "type": "question",
316 "object_id": "584616119",
317 "application": {
318 "name": "Questions",
319 "id": "101502535258"
320 },
321 "created_time": "2013-03-15T19:57:14+0000",
322 "updated_time": "2013-03-15T19:57:14+0000",
323 "likes": {
324 "data": [
325 {
326 "name": "Kevin Diner",
327 "id": "55520"
328 },
329 {
330 "name": "Bozo the Clown",
331 "id": "13960"
332 }
333 ],
334 "count": 3
335 },
336 "comments": {
337 "data": [
338 {
339 "id": "14446143_102008355988977_100927",
340 "from": {
341 "name": "Seymour Butts",
342 "id": "505677"
343 },
344 "message": "seems legit",
345 "created_time": "2013-03-13T12:20:19+0000",
346 "likes": 2
347 },
348 {
349 "id": "120143_1020035588977_1019440",
350 "from": {
351 "name": "Andre the Giant",
352 "id": "100390199"
353 },
354 "message": "Anybody want a peanut?",
355 "created_time": "2013-03-13T12:23:25+0000"
356 }
357 ],
358 "count": 22
359 }
265 }360 }
266 ],361 ],
267 "paging": {362 "paging": {
268363
=== modified file 'friends/tests/test_facebook.py'
--- friends/tests/test_facebook.py 2013-03-14 19:14:03 +0000
+++ friends/tests/test_facebook.py 2013-03-16 01:05:27 +0000
@@ -109,8 +109,8 @@
109 # Receive the wall feed for a user.109 # Receive the wall feed for a user.
110 self.maxDiff = None110 self.maxDiff = None
111 self.account.access_token = 'abc'111 self.account.access_token = 'abc'
112 self.assertEqual(self.protocol.receive(), 9)112 self.assertEqual(self.protocol.receive(), 12)
113 self.assertEqual(TestModel.get_n_rows(), 9)113 self.assertEqual(TestModel.get_n_rows(), 12)
114 self.assertEqual(list(TestModel.get_row(0)), [114 self.assertEqual(list(TestModel.get_row(0)), [
115 'facebook',115 'facebook',
116 88,116 88,
@@ -197,6 +197,32 @@
197 30.265384957204,197 30.265384957204,
198 -97.735604602521,198 -97.735604602521,
199 ])199 ])
200 self.assertEqual(list(TestModel.get_row(9)), [
201 'facebook',
202 88,
203 '104443_100085049977',
204 'mentions',
205 'Guy Frenchie',
206 '1244414',
207 'Guy Frenchie',
208 False,
209 '2013-03-15T19:57:14Z',
210 'Guy Frenchie did some things with some stuff.',
211 GLib.get_user_cache_dir() +
212 '/friends/avatars/3f5e276af0c43f6411d931b829123825ede1968e',
213 'https://www.facebook.com/1244414',
214 3,
215 False,
216 '',
217 '',
218 '',
219 '',
220 '',
221 '',
222 '',
223 0.0,
224 0.0,
225 ])
200226
201 # XXX We really need full coverage of the receive() method, including227 # XXX We really need full coverage of the receive() method, including
202 # cases where some data is missing, or can't be converted228 # cases where some data is missing, or can't be converted
@@ -214,18 +240,18 @@
214 self.account.auth.parameters = dict(240 self.account.auth.parameters = dict(
215 ConsumerKey='key',241 ConsumerKey='key',
216 ConsumerSecret='secret')242 ConsumerSecret='secret')
217 self.assertEqual(self.protocol.home(), 9)243 self.assertEqual(self.protocol.home(), 12)
218244
219 with open(self._root.format('facebook_ids'), 'r') as fd:245 with open(self._root.format('facebook_ids'), 'r') as fd:
220 self.assertEqual(fd.read(), '{"messages": "2013-03-13T23:29:07Z"}')246 self.assertEqual(fd.read(), '{"messages": "2013-03-15T19:57:14Z"}')
221247
222 follow = self.protocol._follow_pagination = mock.Mock()248 follow = self.protocol._follow_pagination = mock.Mock()
223 follow.return_value = []249 follow.return_value = []
224 self.assertEqual(self.protocol.home(), 9)250 self.assertEqual(self.protocol.home(), 12)
225 follow.assert_called_once_with(251 follow.assert_called_once_with(
226 'https://graph.facebook.com/me/home',252 'https://graph.facebook.com/me/home',
227 dict(limit=50,253 dict(limit=50,
228 since='2013-03-13T23:29:07Z',254 since='2013-03-15T19:57:14Z',
229 access_token='access',255 access_token='access',
230 )256 )
231 )257 )

Subscribers

People subscribed via source and target branches