URLs need to have a TweetID lol
This commit is contained in:
parent
32e1558800
commit
c00ff06b3f
@ -149,6 +149,7 @@ func (api_result APIV2Result) ToTweetTrove() TweetTrove {
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("Tweet trove didn't contain its own tweet: %d", api_result.Result.Legacy.ID))
|
||||
}
|
||||
url.TweetID = main_tweet.ID
|
||||
found := false
|
||||
for i := range main_tweet.Urls {
|
||||
if main_tweet.Urls[i].ShortText != url.ShortText {
|
||||
|
@ -291,6 +291,7 @@ func TestAPIV2ParseTweetWithURL(t *testing.T) {
|
||||
|
||||
assert.Equal(1, len(tweet.Urls))
|
||||
url := tweet.Urls[0]
|
||||
assert.Equal(tweet.ID, url.TweetID)
|
||||
assert.Equal("observer.com", url.Domain)
|
||||
assert.Equal("Why Evangelical Progressives Need to Demonstrate Anguish Publicly", url.Title)
|
||||
assert.Equal("https://observer.com/2016/12/why-evangelical-progressives-need-to-demonstrate-anguish-publicly/", url.Text)
|
||||
@ -325,6 +326,7 @@ func TestAPIV2ParseTweetWithURLPlayerCard(t *testing.T) {
|
||||
|
||||
assert.Equal(1, len(tweet.Urls))
|
||||
url := tweet.Urls[0]
|
||||
assert.Equal(tweet.ID, url.TweetID)
|
||||
assert.Equal("www.youtube.com", url.Domain)
|
||||
assert.Equal("Michael Malice on Kennedy Nov. 15, 2016", url.Title)
|
||||
assert.Equal("https://www.youtube.com/watch?v=c9TypEM1ik4&t=9s", url.Text)
|
||||
@ -333,6 +335,33 @@ func TestAPIV2ParseTweetWithURLPlayerCard(t *testing.T) {
|
||||
assert.Equal(UserID(10228272), url.SiteID)
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a tweet with a link with a "player" card
|
||||
*/
|
||||
func TestAPIV2ParseTweetWithURLRetweet(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
data, err := ioutil.ReadFile("test_responses/api_v2/retweet_with_url.json")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var tweet_result APIV2Result
|
||||
err = json.Unmarshal(data, &tweet_result)
|
||||
assert.NoError(err)
|
||||
|
||||
trove := tweet_result.ToTweetTrove()
|
||||
|
||||
assert.Equal(1, len(trove.Tweets))
|
||||
tweet, ok := trove.Tweets[1488605073588559873]
|
||||
assert.True(ok)
|
||||
assert.Equal("REJOICE", tweet.Text)
|
||||
|
||||
assert.Equal(1, len(tweet.Urls))
|
||||
url := tweet.Urls[0]
|
||||
assert.Equal(tweet.ID, url.TweetID)
|
||||
assert.Equal("tippinsights.com", url.Domain)
|
||||
}
|
||||
|
||||
|
||||
func TestParseAPIV2UserFeed(t *testing.T) {
|
||||
data, err := ioutil.ReadFile("test_responses/api_v2/user_feed_apiv2.json")
|
||||
|
1
scraper/test_responses/api_v2/retweet_with_url.json
Normal file
1
scraper/test_responses/api_v2/retweet_with_url.json
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user