Commit graph

7 commits

Author SHA1 Message Date
Phil Gyford
73982c78f4 Fix links in tweets when there's a prefix
If a tweet had a prefix (@names that it was replying to) then the length
of these is counted in the indices that show the locations of entities
within the tweet. But we were applying those indices to the 'display'
part of the tweet that doesn't include the prefix.

So, if the tweet was:

    @bob Please meet @bill

and the prefix was `@bob `, then the indices for linking `@bill`
are something like `17,21`. But we were applying the link around
`@bill` to the display text part of the tweet, which is:

    Please meet @bill

And so the indices no longer lined up with `@bill`.

Now they do, and the same for URLs and hashtags.
2018-01-06 19:03:17 +00:00
Phil Gyford
d3f5361f4d Try to fix loading of JSON files in tests on Travis 2017-10-11 18:40:55 +01:00
Phil Gyford
5a008e7e77 Move all the raw tweets for tests into their own JSON files
Seems better to have the raw data as JSON, like it comes from the API,
then load it into python objects for each test.
2017-10-11 18:27:53 +01:00
Phil Gyford
9ccdb48248 Add test for html_for_tweet() for retweets 2017-10-10 12:31:57 +01:00
Phil Gyford
9ade0946b5 Add test for html_for_tweet() for quoted tweets 2017-10-10 12:24:09 +01:00
Phil Gyford
a27efd9da8 Fix html_for_tweet()s handling of media URLs
We were trying to link to each media item using its
`url`/`expanded_url`. But there is only one of these, shared across
all of a tweet's media items. So attempting to put it in several times,
in the same location, was a bit of a mess!

So it now only puts the `url`/`expanded_url` in once, no matter
how many media items there are.
2017-10-07 18:38:20 +01:00
Phil Gyford
1511ee7b4d Split test_html_for_tweet() tests into their own file 2017-10-07 18:08:01 +01:00