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
1=== modified file 'friends/protocols/facebook.py'
2--- friends/protocols/facebook.py 2013-03-14 02:27:36 +0000
3+++ friends/protocols/facebook.py 2013-03-16 01:05:27 +0000
4@@ -71,7 +71,7 @@
5 args = dict(
6 message_id=message_id,
7 stream=stream,
8- message=entry.get('message', ''),
9+ message=entry.get('message', '') or entry.get('story', ''),
10 icon_uri=entry.get('icon', ''),
11 link_picture=entry.get('picture', ''),
12 link_name=entry.get('name', ''),
13
14=== modified file 'friends/tests/data/facebook-full.dat'
15--- friends/tests/data/facebook-full.dat 2013-03-14 00:52:23 +0000
16+++ friends/tests/data/facebook-full.dat 2013-03-16 01:05:27 +0000
17@@ -262,6 +262,101 @@
18 ],
19 "count": 11
20 }
21+ },
22+ {
23+ "id": "104443_100085049977",
24+ "from": {
25+ "name": "Guy Frenchie",
26+ "id": "1244414"
27+ },
28+ "story": "Guy Frenchie did some things with some stuff.",
29+ "story_tags": {
30+ "0": [
31+ {
32+ "id": "1244414",
33+ "name": "Guy Frenchie",
34+ "offset": 0,
35+ "length": 16,
36+ "type": "user"
37+ }
38+ ],
39+ "26": [
40+ {
41+ "id": "37067557",
42+ "name": "somebody",
43+ "offset": 26,
44+ "length": 10,
45+ "type": "page"
46+ }
47+ ],
48+ "48": [
49+ {
50+ "id": "50681138",
51+ "name": "What do you think about things and stuff?",
52+ "offset": 48,
53+ "length": 52
54+ }
55+ ]
56+ },
57+ "icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yg/r/5PpICR5KcPe.png",
58+ "actions": [
59+ {
60+ "name": "Comment",
61+ "link": "https://www.facebook.com/1244414/posts/100085049977"
62+ },
63+ {
64+ "name": "Like",
65+ "link": "https://www.facebook.com/1244414/posts/100085049977"
66+ }
67+ ],
68+ "privacy": {
69+ "value": ""
70+ },
71+ "type": "question",
72+ "object_id": "584616119",
73+ "application": {
74+ "name": "Questions",
75+ "id": "101502535258"
76+ },
77+ "created_time": "2013-03-15T19:57:14+0000",
78+ "updated_time": "2013-03-15T19:57:14+0000",
79+ "likes": {
80+ "data": [
81+ {
82+ "name": "Kevin Diner",
83+ "id": "55520"
84+ },
85+ {
86+ "name": "Bozo the Clown",
87+ "id": "13960"
88+ }
89+ ],
90+ "count": 3
91+ },
92+ "comments": {
93+ "data": [
94+ {
95+ "id": "14446143_102008355988977_100927",
96+ "from": {
97+ "name": "Seymour Butts",
98+ "id": "505677"
99+ },
100+ "message": "seems legit",
101+ "created_time": "2013-03-13T12:20:19+0000",
102+ "likes": 2
103+ },
104+ {
105+ "id": "120143_1020035588977_1019440",
106+ "from": {
107+ "name": "Andre the Giant",
108+ "id": "100390199"
109+ },
110+ "message": "Anybody want a peanut?",
111+ "created_time": "2013-03-13T12:23:25+0000"
112+ }
113+ ],
114+ "count": 22
115+ }
116 }
117 ],
118 "paging": {
119
120=== modified file 'friends/tests/test_facebook.py'
121--- friends/tests/test_facebook.py 2013-03-14 19:14:03 +0000
122+++ friends/tests/test_facebook.py 2013-03-16 01:05:27 +0000
123@@ -109,8 +109,8 @@
124 # Receive the wall feed for a user.
125 self.maxDiff = None
126 self.account.access_token = 'abc'
127- self.assertEqual(self.protocol.receive(), 9)
128- self.assertEqual(TestModel.get_n_rows(), 9)
129+ self.assertEqual(self.protocol.receive(), 12)
130+ self.assertEqual(TestModel.get_n_rows(), 12)
131 self.assertEqual(list(TestModel.get_row(0)), [
132 'facebook',
133 88,
134@@ -197,6 +197,32 @@
135 30.265384957204,
136 -97.735604602521,
137 ])
138+ self.assertEqual(list(TestModel.get_row(9)), [
139+ 'facebook',
140+ 88,
141+ '104443_100085049977',
142+ 'mentions',
143+ 'Guy Frenchie',
144+ '1244414',
145+ 'Guy Frenchie',
146+ False,
147+ '2013-03-15T19:57:14Z',
148+ 'Guy Frenchie did some things with some stuff.',
149+ GLib.get_user_cache_dir() +
150+ '/friends/avatars/3f5e276af0c43f6411d931b829123825ede1968e',
151+ 'https://www.facebook.com/1244414',
152+ 3,
153+ False,
154+ '',
155+ '',
156+ '',
157+ '',
158+ '',
159+ '',
160+ '',
161+ 0.0,
162+ 0.0,
163+ ])
164
165 # XXX We really need full coverage of the receive() method, including
166 # cases where some data is missing, or can't be converted
167@@ -214,18 +240,18 @@
168 self.account.auth.parameters = dict(
169 ConsumerKey='key',
170 ConsumerSecret='secret')
171- self.assertEqual(self.protocol.home(), 9)
172+ self.assertEqual(self.protocol.home(), 12)
173
174 with open(self._root.format('facebook_ids'), 'r') as fd:
175- self.assertEqual(fd.read(), '{"messages": "2013-03-13T23:29:07Z"}')
176+ self.assertEqual(fd.read(), '{"messages": "2013-03-15T19:57:14Z"}')
177
178 follow = self.protocol._follow_pagination = mock.Mock()
179 follow.return_value = []
180- self.assertEqual(self.protocol.home(), 9)
181+ self.assertEqual(self.protocol.home(), 12)
182 follow.assert_called_once_with(
183 'https://graph.facebook.com/me/home',
184 dict(limit=50,
185- since='2013-03-13T23:29:07Z',
186+ since='2013-03-15T19:57:14Z',
187 access_token='access',
188 )
189 )

Subscribers

People subscribed via source and target branches