-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make htmlify_tweet() more robust when encountering strs not ints
Some tweet JSON have the `display_text_range` set as strings not ints, e.g. `["0", "140"]` rather than `[0, 140]`. Particularly when the JSON has come from the downloaded Twitter archive. And Some tweet JSON have the `["entities"][<kind>]["indices"]` set as strings not ints, e.g. `["0", "9"]` rather than `[0, 9]`. Particularly when the JSON has come from the downloaded Twitter archive. For #229
- Loading branch information
1 parent
81d3c0a
commit 4948f07
Showing
4 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
tests/twitter/fixtures/api/tweet_with_display_text_range_str.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"retweeted": false, | ||
"source": "<a href=\"http://tapbots.com/tweetbot\" rel=\"nofollow\">Tweetbot for iΟS</a>", | ||
"entities": { | ||
"hashtags": [], | ||
"symbols": [], | ||
"user_mentions": [], | ||
"urls": [] | ||
}, | ||
"display_text_range": ["0", "140"], | ||
"favorite_count": "6", | ||
"id_str": "915152022273449987", | ||
"truncated": false, | ||
"retweet_count": "0", | ||
"id": "915152022273449987", | ||
"created_at": "Tue Oct 03 09:50:19 +0000 2017", | ||
"favorited": false, | ||
"full_text": "Open iPad Slack, scroll to bottom. Close Slack. Open Slack; it’s scrolled back up. Every time. Maddening. Not biggest problem in world, BUT.", | ||
"lang": "en" | ||
} |
40 changes: 40 additions & 0 deletions
40
tests/twitter/fixtures/api/tweet_with_entities_indices_str.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"retweeted": false, | ||
"source": "<a href=\"https://tapbots.com/software/tweetbot/mac\" rel=\"nofollow\">Tweetbot for Mac</a>", | ||
"entities": { | ||
"hashtags": [], | ||
"symbols": [], | ||
"user_mentions": [ | ||
{ | ||
"name": "Terry Collier", | ||
"screen_name": "terrycol", | ||
"indices": ["0", "9"], | ||
"id_str": "123", | ||
"id": "123" | ||
}, | ||
{ | ||
"name": "Bob Ferris", | ||
"screen_name": "bobferris", | ||
"indices": ["10", "20"], | ||
"id_str": "234", | ||
"id": "234" | ||
} | ||
], | ||
"urls": [] | ||
}, | ||
"display_text_range": [0, 142], | ||
"favorite_count": "0", | ||
"in_reply_to_status_id_str": "914906397061664768", | ||
"id_str": "914908752482111488", | ||
"in_reply_to_user_id": "123", | ||
"truncated": false, | ||
"retweet_count": "0", | ||
"id": "914908752482111488", | ||
"in_reply_to_status_id": "914906397061664768", | ||
"created_at": "Mon Oct 02 17:43:39 +0000 2017", | ||
"favorited": false, | ||
"full_text": "@terrycol @bobferris I liked it and only thought some of it was a bit silly. But analysis beyond that is probably beyond the scope of Twitter.", | ||
"lang": "en", | ||
"in_reply_to_screen_name": "terrycol", | ||
"in_reply_to_user_id_str": "123" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters