Merge lp:~robru/friends/tco into lp:friends

Proposed by Robert Bruce Park on 2013-04-13
Status: Merged
Approved by: Ken VanDine on 2013-04-16
Approved revision: 191
Merged at revision: 194
Proposed branch: lp:~robru/friends/tco
Merge into: lp:friends
Diff against target: 41 lines (+16/-2)
2 files modified
friends/protocols/twitter.py (+14/-1)
friends/tests/test_twitter.py (+2/-1)
To merge this branch: bzr merge lp:~robru/friends/tco
Reviewer Review Type Date Requested Status
Ken VanDine 2013-04-13 Approve on 2013-04-16
PS Jenkins bot (community) continuous-integration Approve on 2013-04-13
Review via email: mp+158737@code.launchpad.net

Commit message

Resolve t.co links, with test coverage. (LP: #1166080)

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :

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

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

review: Approve (continuous-integration)
lp:~robru/friends/tco updated on 2013-04-13
190. By Robert Bruce Park on 2013-04-13

Fix a bug where it would not resolve TCO links at the beginning of the message.

PS Jenkins bot (ps-jenkins) wrote :

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

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

review: Approve (continuous-integration)
lp:~robru/friends/tco updated on 2013-04-13
191. By Robert Bruce Park on 2013-04-13

Don't default to empty string for the substitute URL.

PS Jenkins bot (ps-jenkins) wrote :

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

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

review: Approve (continuous-integration)
Ken VanDine (ken-vandine) wrote :

Looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'friends/protocols/twitter.py'
2--- friends/protocols/twitter.py 2013-04-03 03:47:39 +0000
3+++ friends/protocols/twitter.py 2013-04-13 18:18:23 +0000
4@@ -120,9 +120,22 @@
5 permalink = self._tweet_permalink.format(
6 user_id=screen_name,
7 tweet_id=tweet_id)
8+
9+ message = tweet.get('text', '')
10+
11+ # Resolve t.co links.
12+ entities = tweet.get('entities', {})
13+ for url in (entities.get('urls', []) + entities.get('media', [])):
14+ begin, end = url.get('indices', (None, None))
15+ destination = (url.get('expanded_url') or
16+ url.get('display_url') or
17+ url.get('url'))
18+ if None not in (begin, end, destination):
19+ message = message[:begin] + destination + message[end:]
20+
21 self._publish(
22 message_id=tweet_id,
23- message=tweet.get('text', ''),
24+ message=message,
25 timestamp=iso8601utc(parsetime(tweet.get('created_at', ''))),
26 stream=stream,
27 sender=user.get('name', ''),
28
29=== modified file 'friends/tests/test_twitter.py'
30--- friends/tests/test_twitter.py 2013-04-02 21:46:47 +0000
31+++ friends/tests/test_twitter.py 2013-04-13 18:18:23 +0000
32@@ -143,7 +143,8 @@
33 'messages', 'Raffi Krikorian', '8285392', 'raffi', False,
34 '2012-08-28T21:08:15Z', 'lecturing at the "analyzing big data '
35 'with twitter" class at @cal with @othman '
36- '<a href="http://t.co/bfj7zkDJ">http://t.co/bfj7zkDJ</a>',
37+ '<a href="http://blogs.ischool.berkeley.edu/i290-abdt-s12/">'
38+ 'http://blogs.ischool.berkeley.edu/i290-abdt-s12/</a>',
39 GLib.get_user_cache_dir() +
40 '/friends/avatars/0219effc03a3049a622476e6e001a4014f33dc31',
41 'https://twitter.com/raffi/status/240556426106372096',

Subscribers

People subscribed via source and target branches