Merge lp:~phanimahesh/friends/friends into lp:friends

Proposed by J Phani Mahesh
Status: Merged
Merged at revision: 206
Proposed branch: lp:~phanimahesh/friends/friends
Merge into: lp:friends
Diff against target: 152 lines (+19/-16)
3 files modified
friends/protocols/facebook.py (+5/-2)
friends/tests/data/facebook-full.dat (+7/-7)
friends/tests/test_facebook.py (+7/-7)
To merge this branch: bzr merge lp:~phanimahesh/friends/friends
Reviewer Review Type Date Requested Status
Robert Bruce Park Approve
Review via email: mp+166449@code.launchpad.net

Description of the change

Proposed fix for LP:#1185684

Corrects the url on posts from facebook feed to point at the permalink instead of the timeline.

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

Hi, thanks for submitting this patch. It looks nice and simple, but I really need to see some test coverage with it. Make sure you run the test suite and update the tests in test_facebook.py in order to reflect this change.

review: Needs Fixing
Revision history for this message
J Phani Mahesh (phanimahesh) wrote :

I'm not familiar with 'mock', which seems to be used for the unit tests. I've noticed that the tests fail, but was unable to identify what caused the failure. I'll give it a try once again.
Do you have any tips that might help in finding the cause of failure?

I've patched up my installation ( dog-fooding? :P) and it works great for me.

Revision history for this message
Robert Bruce Park (robru) wrote :

I had a quick look at the tests, and what I saw was that the mock data we
use in the testsuite doesn't have an underscore, so it's raising IndexError
because the call to split is ineffective. So you'll have to read the
traceback, and then follow the code path backwards to see where the mock
data is being defined (usually within each test it should declare some
dummy data). then you'll have to change the value to have the expected
number of underscores in it, with some arbitrary letters or numbers in
between. once you have that in place, then what'll happen is that the tests
will fail, because they expect the old timeline URL and not the new page
URL you're implementing. so just update the actual assertions to start
expecting the new URL, and that should pretty much do it.

On Mon, Jun 10, 2013 at 11:40 PM, J Phani Mahesh <
<email address hidden>> wrote:

> I'm not familiar with 'mock', which seems to be used for the unit tests.
> I've noticed that the tests fail, but was unable to identify what caused
> the failure. I'll give it a try once again.
> Do you have any tips that might help in finding the cause of failure?
>
> I've patched up my installation ( dog-fooding? :P) and it works great for
> me.
> --
> https://code.launchpad.net/~phanimahesh/friends/friends/+merge/166449
> You are reviewing the proposed merge of lp:~phanimahesh/friends/friends
> into lp:friends.
>

Revision history for this message
J Phani Mahesh (phanimahesh) wrote :

Hello Robert!

Thanks for the pointers. That was easy. please find the tests updated.

Revision history for this message
Robert Bruce Park (robru) wrote :

Great work, thanks!

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-04-02 21:30:43 +0000
3+++ friends/protocols/facebook.py 2013-06-12 06:40:33 +0000
4@@ -39,7 +39,7 @@
5 API_BASE = URL_BASE.format(subdomain='graph') + '{id}'
6 ME_URL = API_BASE.format(id='me')
7 FACEBOOK_ADDRESS_BOOK = 'friends-facebook-contacts'
8-
9+STORY_PERMALINK = PERMALINK + '/posts/{post_id}'
10
11 TEN_DAYS = 864000 # seconds
12
13@@ -93,12 +93,15 @@
14 if from_record is not None:
15 args['sender'] = from_record.get('name', '')
16 args['sender_id'] = sender_id = from_record.get('id', '')
17- args['url'] = PERMALINK.format(id=sender_id)
18 args['icon_uri'] = Avatar.get_image(
19 API_BASE.format(id=sender_id) + '/picture?width=840&height=840')
20 args['sender_nick'] = from_record.get('name', '')
21 args['from_me'] = (sender_id == self._account.user_id)
22
23+ # Fix for LP:1185684 - JPM
24+ post_id= message_id.split('_')[1]
25+ args['url'] = STORY_PERMALINK.format(id=sender_id,post_id=post_id)
26+
27 # Normalize the timestamp.
28 timestamp = entry.get('updated_time', entry.get('created_time'))
29 if timestamp is not None:
30
31=== modified file 'friends/tests/data/facebook-full.dat'
32--- friends/tests/data/facebook-full.dat 2013-03-16 00:54:45 +0000
33+++ friends/tests/data/facebook-full.dat 2013-06-12 06:40:33 +0000
34@@ -1,7 +1,7 @@
35 {
36 "data": [
37 {
38- "id": "fake_id",
39+ "id": "userid_postid1",
40 "from": {
41 "name": "Yours Truly",
42 "id": "56789"
43@@ -10,11 +10,11 @@
44 "actions": [
45 {
46 "name": "Comment",
47- "link": "https://www.facebook.com/fake/posts/id"
48+ "link": "https://www.facebook.com/userid/posts/postid1"
49 },
50 {
51 "name": "Like",
52- "link": "https://www.facebook.com/fake/posts/id"
53+ "link": "https://www.facebook.com/userid/posts/postid1"
54 }
55 ],
56 "privacy": {
57@@ -46,7 +46,7 @@
58 "comments": {
59 "data": [
60 {
61- "id": "fake as a snake",
62+ "id": "postid1_commentid1",
63 "from": {
64 "name": "Grandma",
65 "id": "9876"
66@@ -55,7 +55,7 @@
67 "created_time": "2013-03-12T22:56:17+0000"
68 },
69 {
70- "id": "faker than cake!",
71+ "id": "postid1_commentid2",
72 "from": {
73 "name": "Father",
74 "id": "234"
75@@ -64,7 +64,7 @@
76 "created_time": "2013-03-12T23:29:45+0000"
77 },
78 {
79- "id": "still fake",
80+ "id": "postid1_commentid3",
81 "from": {
82 "name": "Mother",
83 "id": "456"
84@@ -73,7 +73,7 @@
85 "created_time": "2013-03-13T02:20:27+0000"
86 },
87 {
88- "id": "this one is real",
89+ "id": "postid1_commentid4",
90 "from": {
91 "name": "Yours Truly",
92 "id": "56789"
93
94=== modified file 'friends/tests/test_facebook.py'
95--- friends/tests/test_facebook.py 2013-04-02 21:54:24 +0000
96+++ friends/tests/test_facebook.py 2013-06-12 06:40:33 +0000
97@@ -119,7 +119,7 @@
98 self.assertEqual(list(TestModel.get_row(0)), [
99 'facebook',
100 88,
101- 'fake_id',
102+ 'userid_postid1',
103 'mentions',
104 'Yours Truly',
105 '56789',
106@@ -131,7 +131,7 @@
107 'to test with, that\'d be super.',
108 GLib.get_user_cache_dir() +
109 '/friends/avatars/5c4e74c64b1a09343558afc1046c2b1d176a2ba2',
110- 'https://www.facebook.com/56789',
111+ 'https://www.facebook.com/56789/posts/postid1',
112 1,
113 False,
114 '',
115@@ -147,8 +147,8 @@
116 self.assertEqual(list(TestModel.get_row(2)), [
117 'facebook',
118 88,
119- 'faker than cake!',
120- 'reply_to/fake_id',
121+ 'postid1_commentid2',
122+ 'reply_to/userid_postid1',
123 'Father',
124 '234',
125 'Father',
126@@ -157,7 +157,7 @@
127 'don\'t know how',
128 GLib.get_user_cache_dir() +
129 '/friends/avatars/9b9379ccc7948e4804dff7914bfa4c6de3974df5',
130- 'https://www.facebook.com/234',
131+ 'https://www.facebook.com/234/posts/commentid2',
132 0,
133 False,
134 '',
135@@ -188,7 +188,7 @@
136 'producer, Sean Keegan. Stanley is in the lobby.',
137 GLib.get_user_cache_dir() +
138 '/friends/avatars/5b2d70e788df790b9c8db4c6a138fc4a1f433ec9',
139- 'https://www.facebook.com/161247843901324',
140+ 'https://www.facebook.com/161247843901324/posts/629147610444676',
141 84,
142 False,
143 'https://fbcdn-photos-a.akamaihd.net/hphotos-ak-snc7/' +
144@@ -215,7 +215,7 @@
145 'Guy Frenchie did some things with some stuff.',
146 GLib.get_user_cache_dir() +
147 '/friends/avatars/3f5e276af0c43f6411d931b829123825ede1968e',
148- 'https://www.facebook.com/1244414',
149+ 'https://www.facebook.com/1244414/posts/100085049977',
150 3,
151 False,
152 '',

Subscribers

People subscribed via source and target branches

to all changes: