Skip to content

Commit

Permalink
Fix contributors field (#36)
Browse files Browse the repository at this point in the history
On rare occasions, contributors field is actually populated and original 
definition was set as Dict instead of Array
  • Loading branch information
Randy Zwitch authored Jan 28, 2020
1 parent 6fcea70 commit 351e7af
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ language: julia
os:
- linux
julia:
- 1.0
- 1.1
- 1.2
- 1.3
- nightly
matrix:
Expand Down
2 changes: 1 addition & 1 deletion src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ end

#Tweets response object
mutable struct Tweets <: TwitterType
contributors::Union{Dict, Nothing}
contributors::Union{Array, Nothing}
coordinates::Union{Dict, Nothing}
created_at::Union{String, Nothing}
current_user_retweet::Union{Dict, Nothing}
Expand Down
32 changes: 30 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,32 @@ tw_df = DataFrame(mentions_timeline_default)
@test typeof(tw) == Tweets
@test size(tw_df)[2] == 30

sleep(5)

#get_user_timeline
user_timeline_default = get_user_timeline(screen_name = "randyzwitch")
@test typeof(user_timeline_default) == Vector{Tweets}

sleep(5)

#get_home_timeline
home_timeline_default = get_home_timeline()
@test typeof(home_timeline_default) == Vector{Tweets}

sleep(5)

#get_single_tweet_id
get_tweet_by_id = get_single_tweet_id(id = "434685122671939584")
@test typeof(get_tweet_by_id) == Tweets

sleep(5)

#get_search_tweets
duke_tweets = get_search_tweets(q = "#Duke", count = 200)
@test typeof(duke_tweets) <: Dict

sleep(5)

#test sending/deleting direct messages
#commenting out because Twitter API changed. Come back to fix
# send_dm = post_direct_messages_send(text = "Testing from Julia, this might disappear later $(time())", screen_name = "randyzwitch")
Expand All @@ -39,37 +49,55 @@ duke_tweets = get_search_tweets(q = "#Duke", count = 200)

#creating/destroying friendships
add_friend = post_friendships_create(screen_name = "kyrieirving")

sleep(5)

unfollow = post_friendships_destroy(screen_name = "kyrieirving")
unfollow_df = DataFrame(unfollow)
@test typeof(add_friend) == Users
@test typeof(unfollow) == Users
@test size(unfollow_df)[2] == 40

sleep(5)

# create a cursor for follower ids
follow_cursor_test = get_followers_ids(screen_name = "twitter", count = 10_000)
@test length(follow_cursor_test["ids"]) == 10_000

sleep(5)

# create a cursor for friend ids - use barackobama because he follows a lot of accounts!
friend_cursor_test = get_friends_ids(screen_name = "BarackObama", count = 10_000)
@test length(friend_cursor_test["ids"]) == 10_000

sleep(5)

# create a test for home timelines
home_t = get_home_timeline(count = 2)
@test length(home_t) > 1

sleep(5)

# TEST of cursoring functionality on user timelines
user_t = get_user_timeline(screen_name = "stefanjwojcik", count = 400)
@test length(user_t) == 400
# get the minimum ID of the tweets returned (the earliest)
minid = minimum(x.id for x in user_t)

sleep(5)

# now iterate until you hit that tweet: should return 399
tweets_since = get_user_timeline(screen_name = "stefanjwojcik", count = 400, since_id = minid, include_rts=1)
@test length(tweets_since)==399

sleep(5)

# testing get_mentions_timeline
mentions = get_mentions_timeline(screen_name = "stefanjwojcik", count = 300)
@test length(mentions) >= 300
@test Tweets<:typeof(tweets[1])
@test length(mentions) >= 200 #sometimes API doesn't return number requested
@test Tweets<:typeof(mentions[1])

sleep(5)

# testing retweets_of_me
my_rts = get_retweets_of_me(count = 300)
Expand Down

0 comments on commit 351e7af

Please sign in to comment.