Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

Commit

Permalink
Update test format fix #270 (#284)
Browse files Browse the repository at this point in the history
* Fix `test-deprecate` ref #270

* Fix `test-emptyreturn` ref #270

* Fix `tes-get_all_tweets.R` ref #270

* Fix `test-set_bearer.R` ref #270

* Fix `test-update` ref #270

* Fix `test-resume` ref #270

* Fix `test-get_user_functions.R` ref #270

* Fix `test-get_liked_tweets.R` ref #270

* Fix `test-get_liking_users.R` ref #270

* Fix `test-get_retweeted_by.R` ref #270

* Fix `test-get_user_timeline.R` ref #270

* Fix `test-count_all_tweets.R` ref #270

* Fix `test-make_query` ref #270

* Fix `test-real.R` ref #270

This one is tricky because it doesn't use the mock API. Instead, we
need to skip this test when no TWITTER_BEARER has been set.

* Fix `test-flat.R` ref #270

* Fix `test-sleep.R` ref #270

* Fix `test-context_annotations.R` and `test-missing_header.R` ref #270

* Fix `test-issue231.R` ref #270

* Fix `test-exact.R` ref #270

* Fix `test-get_user_id.R` ref #270

* Remove the `devtools::test` in GHA ref #270
  • Loading branch information
chainsawriot authored Feb 5, 2022
1 parent 1404bc3 commit b65656c
Show file tree
Hide file tree
Showing 23 changed files with 73 additions and 36 deletions.
21 changes: 0 additions & 21 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,6 @@ cran-comments.md
^\.github$
^tests/testthat/api\.twitter\.com/
^tests/testthat/storage\.googleapis\.com/
^tests/testthat/test-deprecate\.R
^tests/testthat/test-emptyreturn\.R
^tests/testthat/test-get_all_tweets\.R
^tests/testthat/test-set_bearer\.R
^tests/testthat/test-update\.R
^tests/testthat/test-resume\.R
^tests/testthat/test-get_user_functions\.R
^tests/testthat/test-get_liked_tweets\.R
^tests/testthat/test-get_liking_users\.R
^tests/testthat/test-get_retweeted_by\.R
^tests/testthat/test-get_user_timeline\.R
^tests/testthat/test-count_all_tweets\.R
^tests/testthat/test-make_query\.R
^tests/testthat/test-real\.R
^tests/testthat/test-flat\.R
^tests/testthat/test-sleep\.R
^tests/testthat/test-context_annotations\.R
^tests/testthat/test-missing_header\.R
^tests/testthat/test-issue213\.R
^tests/testthat/test-exact\.R
^tests/testthat/test-get_user_id\.R
^tests/testthat/_snap
^tests/testdata/.+\.RDS
^tests/testdata/hk
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,8 @@ jobs:
run: |
options(crayon.enabled = TRUE)
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
sink("bigtest.txt"); devtools::test(reporter = "summary"); sink(file = NULL)
shell: Rscript {0}

- name: Show testthat output
if: always()
run: cat 'bigtest.txt' || true
shell: bash

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-context_annotations.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ test_that("add_context_annotations works", {

with_mock_api({
test_that("expected output", {
skip_if(!dir.exists("api.twitter.com"))
capture_warnings(x <- get_all_tweets(query = "#commtwitter", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-05T00:00:00Z", context_annotations = FALSE))
expect_false("context_annotations" %in% colnames(x))
capture_warnings(y <- get_all_tweets(query = "#commtwitter", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-05T00:00:00Z", context_annotations = TRUE))
Expand All @@ -50,6 +51,8 @@ with_mock_api({

with_mock_api({
test_that("visual output", {
skip_if(!dir.exists("api.twitter.com"))
skip_if(!dir.exists("_snaps"))
expect_snapshot({
capture_warnings(x <- get_all_tweets(query = "#commtwitter", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-05T00:00:00Z", context_annotations = FALSE, verbose = TRUE))
capture_warnings(y <- get_all_tweets(query = "#commtwitter", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-05T00:00:00Z", context_annotations = TRUE, verbose = TRUE))
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-count_all_tweets.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

with_mock_api({
test_that("expected behavior, #153", {
skip_if(!dir.exists("api.twitter.com"))
ori_test <- "../testdata/commtwitter/"
res <- count_all_tweets(query = "#commtwitter", start_tweets = "2021-03-01T00:00:00Z", end_tweets = "2021-06-05T00:00:00Z")
prev_res <- readRDS("../testdata/count_all_tweets.RDS")
Expand Down
14 changes: 14 additions & 0 deletions tests/testthat/test-deprecate.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ test_that("bind_user_jsons", {

with_mock_api({
test_that("get_retweets_of_user", {
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()
lifecycle::expect_deprecated(get_retweets_of_user(users = "kfc", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-05T00:00:00Z", data_path = emptydir, bind_tweets = FALSE, verbose = FALSE))
unlink(emptydir, recursive = TRUE)
Expand All @@ -26,6 +27,7 @@ with_mock_api({

with_mock_api({
test_that("get_to_tweets", {
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()
lifecycle::expect_deprecated(get_to_tweets(users = "kfc", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-05T00:00:00Z", data_path = emptydir, bind_tweets = FALSE, verbose = FALSE))
unlink(emptydir, recursive = TRUE)
Expand All @@ -39,6 +41,7 @@ with_mock_api({

with_mock_api({
test_that("get_users_tweets", {
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()
lifecycle::expect_deprecated(get_user_tweets(users = "kfc", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-05T00:00:00Z", data_path = emptydir, bind_tweets = FALSE, verbose = FALSE))
unlink(emptydir, recursive = TRUE)
Expand All @@ -52,6 +55,7 @@ with_mock_api({

with_mock_api({
test_that("get_video_tweets", {
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()
lifecycle::expect_deprecated(get_video_tweets(query = "#FallonTonight", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-05T00:00:00Z", data_path = emptydir, bind_tweets = FALSE, verbose = FALSE))
unlink(emptydir, recursive = TRUE)
Expand All @@ -65,6 +69,7 @@ with_mock_api({

with_mock_api({
test_that("get_radius_tweets", {
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()
lifecycle::expect_deprecated(get_radius_tweets(query = "happy", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-05T00:00:00Z", radius = c(-0.131969125179604,51.50847878040284, 25), data_path = emptydir, bind_tweets = FALSE, verbose = FALSE))
unlink(emptydir, recursive = TRUE)
Expand All @@ -78,6 +83,7 @@ with_mock_api({

with_mock_api({
test_that("get_bbox_tweets", {
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()
lifecycle::expect_deprecated(get_bbox_tweets(query = "happy", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-05T00:00:00Z", bbox = c(-0.222473,51.442453,0.072784,51.568534), data_path = emptydir, bind_tweets = FALSE, verbose = FALSE))
unlink(emptydir, recursive = TRUE)
Expand All @@ -91,6 +97,7 @@ with_mock_api({

with_mock_api({
test_that("get_mentions_tweets", {
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()
lifecycle::expect_deprecated(get_mentions_tweets(query = "happy", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-05T00:00:00Z", data_path = emptydir, bind_tweets = FALSE, verbose = FALSE))
unlink(emptydir, recursive = TRUE)
Expand All @@ -104,6 +111,7 @@ with_mock_api({

with_mock_api({
test_that("get_lang_tweets", {
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()
lifecycle::expect_deprecated(get_lang_tweets(query = "#IchBinHanna", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-13T00:00:00Z", lang = "de", data_path = emptydir, bind_tweets = FALSE, verbose = FALSE))
unlink(emptydir, recursive = TRUE)
Expand All @@ -117,6 +125,7 @@ with_mock_api({

with_mock_api({
test_that("get_country_tweets", {
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()
lifecycle::expect_deprecated(get_country_tweets(query = "#IchBinHanna", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-13T00:00:00Z", country = "DE", data_path = emptydir, bind_tweets = FALSE, verbose = FALSE))
unlink(emptydir, recursive = TRUE)
Expand All @@ -130,6 +139,7 @@ with_mock_api({

with_mock_api({
test_that("get_place_tweets", {
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()
lifecycle::expect_deprecated(get_place_tweets(query = "#IchBinHanna", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-13T00:00:00Z", place = "Berlin", data_path = emptydir, bind_tweets = FALSE, verbose = FALSE))
unlink(emptydir, recursive = TRUE)
Expand All @@ -143,6 +153,7 @@ with_mock_api({

with_mock_api({
test_that("get_image_tweets", {
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()
lifecycle::expect_deprecated(get_image_tweets(query = "#IchBinHanna", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-13T00:00:00Z", data_path = emptydir, bind_tweets = FALSE, verbose = FALSE))
unlink(emptydir, recursive = TRUE)
Expand All @@ -156,6 +167,7 @@ with_mock_api({

with_mock_api({
test_that("get_media_tweets", {
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()
lifecycle::expect_deprecated(get_media_tweets(query = "#IchBinHanna", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-13T00:00:00Z", data_path = emptydir, bind_tweets = FALSE, verbose = FALSE))
unlink(emptydir, recursive = TRUE)
Expand All @@ -169,6 +181,7 @@ with_mock_api({

with_mock_api({
test_that("get_url_tweets", {
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()
lifecycle::expect_deprecated(get_url_tweets(query = "cdc.gov", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-13T00:00:00Z", data_path = emptydir, bind_tweets = FALSE, verbose = FALSE))
unlink(emptydir, recursive = TRUE)
Expand All @@ -182,6 +195,7 @@ with_mock_api({

with_mock_api({
test_that("get_geo_tweets", {
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()
lifecycle::expect_deprecated(get_geo_tweets(query = "#rstats", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-13T00:00:00Z", data_path = emptydir, bind_tweets = FALSE, verbose = FALSE))
unlink(emptydir, recursive = TRUE)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-emptyreturn.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

with_mock_api({
test_that("empty return, #88", {
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()
expect_error(get_all_tweets("#Figliuolo", "2020-12-01T00:00:00Z", "2020-12-31T00:00:00Z", n=100000, data_path= emptydir, lang = "it", bind_tweets = FALSE), NA)
unlink(emptydir, recursive = TRUE)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-exact.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ test_that("basic test", {

with_mock_api({
test_that("basic test", {
skip_if(!dir.exists("api.twitter.com"))
tweets1 <-
suppressWarnings(get_all_tweets(
query = "Black Lives Matter",
Expand Down
12 changes: 12 additions & 0 deletions tests/testthat/test-flat.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
test_that("defensive programming", {
skip_if(!dir.exists("../testdata/commtwitter"))
expect_error(bind_tweets("../testdata/commtwitter", output_format = "raw"), NA)
expect_error(bind_tweets("../testdata/commtwitter", output_format = "tidy"), NA)
expect_error(bind_tweets("../testdata/commtwitter", output_format = "idontknow"))
Expand All @@ -9,6 +10,7 @@ test_that("defensive programming", {
})

test_that("convert_json", {
skip_if(!dir.exists("../testdata/commtwitter"))
x <- convert_json("../testdata/commtwitter/data_1399765322509557763.json")
expect_equal(colnames(x), c("tweet_id", "user_username", "text", "source", "conversation_id", "author_id", "created_at", "possibly_sensitive", "lang", "user_profile_image_url", "user_location", "user_url", "user_name", "user_pinned_tweet_id", "user_protected", "user_created_at", "user_verified", "user_description", "retweet_count", "like_count", "quote_count", "user_tweet_count", "user_list_count", "user_followers_count", "user_following_count", "sourcetweet_type", "sourcetweet_id", "sourcetweet_text", "sourcetweet_lang", "sourcetweet_author_id"))
expect_true("tbl_df" %in% class(x))
Expand All @@ -18,19 +20,22 @@ test_that("convert_json", {

test_that("issue #273", {
## There are some weird case there is no source tweets; because there are only replies
skip_if(!dir.exists("../testdata/reuters"))
expect_error(convert_json("../testdata/reuters/data_1219780709600124929.json", output_format = "raw"), NA)
expect_error(convert_json("../testdata/reuters/data_1219780709600124929.json", output_format = "tidy"), NA)
expect_error(bind_tweets("../testdata/reuters", verbose = FALSE, output_format = "tidy"), NA)
})

test_that("expected format", {
skip_if(!dir.exists("../testdata/commtwitter"))
x <- bind_tweets("../testdata/commtwitter", output_format = "raw")
expect_equal(class(x), "list")
x <- bind_tweets("../testdata/commtwitter", output_format = "tidy")
expect_true("tbl_df" %in% class(x))
})

test_that("expected dimensionality", {
skip_if(!dir.exists("../testdata/commtwitter"))
x <- bind_tweets("../testdata/commtwitter", output_format = NA, verbose = FALSE)
y <- bind_tweets("../testdata/commtwitter", output_format = "tidy")
expect_equal(nrow(x), nrow(y))
Expand All @@ -45,6 +50,10 @@ test_that("expected dimensionality", {
## x <- get_all_tweets(build_query("#standwithhongkong"), n = 3000, start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-22T23:59:59Z", data_path = "../testdata/hk3", is_retweet = FALSE, is_quote = FALSE, is_reply = TRUE)

test_that(".simple_unnest", {
skip_if(!file.exists("../testdata/hkx.RDS"))
skip_if(!file.exists("../testdata/hkx_pki.RDS"))
skip_if(!file.exists("../testdata/c1.RDS"))
skip_if(!file.exists("../testdata/c1_pki.RDS"))
x <- readRDS("../testdata/hkx.RDS")
pki <- readRDS("../testdata/hkx_pki.RDS")
expect_error(academictwitteR:::.simple_unnest(x, pki), NA)
Expand All @@ -55,6 +64,9 @@ test_that(".simple_unnest", {

test_that("corner cases", {
## only organic tweets
skip_if(!dir.exists("../testdata/hk"))
skip_if(!dir.exists("../testdata/hk2"))
skip_if(!dir.exists("../testdata/hk3"))
res <- bind_tweets("../testdata/hk", output_format = "tidy")
ori <- bind_tweets("../testdata/hk", verbose = FALSE)
expect_equal(nrow(res), nrow(ori))
Expand Down
24 changes: 15 additions & 9 deletions tests/testthat/test-get_all_tweets.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,26 @@ test_that("defensive programming", {

with_mock_api({
test_that("params: default", {
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()
## "Normal" usage; at least the default
expect_error(w0 <- capture_warnings(get_all_tweets(query = "#commtwitter", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-05T00:00:00Z")), NA)
unlink(emptydir, recursive = TRUE)
})
test_that("params: data_path", {
emptydir <- academictwitteR:::.gen_random_dir()
expect_error(w1 <- capture_warnings(get_all_tweets(query = "#commtwitter", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-05T00:00:00Z", verbose = TRUE, data_path = emptydir)), NA)
expect_match(w1, "Tweets will be bound", all = FALSE)
expect_true(length(list.files(emptydir)) != 0) ### side effect is there
## warning message when the data_path is not empty
w2 <- capture_warnings(get_all_tweets(query = "#commtwitter", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-05T00:00:00Z", verbose = TRUE, data_path = emptydir))
expect_match(w2, "Tweets will be bound", all = FALSE)
expect_match(w2, "Directory already exists", all = FALSE)
unlink(emptydir, recursive = TRUE)
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()
expect_error(w1 <- capture_warnings(get_all_tweets(query = "#commtwitter", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-05T00:00:00Z", verbose = TRUE, data_path = emptydir)), NA)
expect_match(w1, "Tweets will be bound", all = FALSE)
expect_true(length(list.files(emptydir)) != 0) ### side effect is there
## warning message when the data_path is not empty
w2 <- capture_warnings(get_all_tweets(query = "#commtwitter", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-05T00:00:00Z", verbose = TRUE, data_path = emptydir))
expect_match(w2, "Tweets will be bound", all = FALSE)
expect_match(w2, "Directory already exists", all = FALSE)
unlink(emptydir, recursive = TRUE)
})
test_that("param: bind_tweets", {
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()

## bind_tweets is FALSE and data_path is NULL: error
Expand All @@ -58,6 +61,7 @@ with_mock_api({
unlink(emptydir, recursive = TRUE)
})
test_that("param: verbose", {
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()
expect_silent(get_all_tweets(query = "#commtwitter", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-05T00:00:00Z", verbose = FALSE, data_path = emptydir, bind_tweets = FALSE))
unlink(emptydir, recursive = TRUE)
Expand All @@ -78,6 +82,7 @@ with_mock_api({
unlink(emptydir, recursive = TRUE)
})
test_that("param: file", {
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()
temp_RDS <- "aaa.RDS"
expect_error(capture_warnings(get_all_tweets(query = "#commtwitter", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-05T00:00:00Z", verbose = TRUE, data_path = emptydir, bind_tweets = FALSE, file = temp_RDS)), NA)
Expand All @@ -90,6 +95,7 @@ with_mock_api({
})

test_that("param: export_query", {
skip_if(!dir.exists("api.twitter.com"))
emptydir <- academictwitteR:::.gen_random_dir()
capture_warnings(get_all_tweets(query = "#commtwitter", start_tweets = "2021-06-01T00:00:00Z", end_tweets = "2021-06-05T00:00:00Z", verbose = TRUE, data_path = emptydir, bind_tweets = FALSE, export_query = TRUE))
expect_true(file.exists(paste0(emptydir, "/query")))
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-get_liked_tweets.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

with_mock_api({
test_that("expected behavior", {
skip_if(!dir.exists("api.twitter.com"))
x <- get_all_tweets("from:k_sze OR from:noahwp", start_tweets = "2021-01-01T00:00:00Z", end_tweets = "2021-06-01T00:00:00Z", verbose = FALSE)
user_ids <- unique(x$author_id)
res <- get_liked_tweets(x = user_ids)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-get_liking_users.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

with_mock_api({
test_that("expected behavior, #153", {
skip_if(!dir.exists("api.twitter.com"))
ori_test <- "../testdata/commtwitter/"
tweet_ids <- unique(bind_tweets(ori_test, verbose = FALSE)$id)
res <- get_liking_users(x = tweet_ids)
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-get_retweeted_by.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

with_mock_api({
test_that("expected behavior, #153", {
skip_if(!dir.exists("api.twitter.com"))
res <- get_retweeted_by("1423714771384340481")
expect_equal(nrow(res), 2) ## no page flipping
})
Expand All @@ -17,20 +18,23 @@ with_mock_api({

with_mock_api({
test_that("zero row behavior", {
skip_if(!dir.exists("api.twitter.com"))
expect_error(res <- get_retweeted_by("1399797349296197635"), NA)
expect_equal(nrow(res), 0)
})
})

with_mock_api({
test_that("x is a vector", {
skip_if(!dir.exists("api.twitter.com"))
expect_error(res <- get_retweeted_by(c("1399797349296197635", "1423714771384340481")), NA)
expect_equal(nrow(res), 2)
})
})

with_mock_api({
test_that("verbose behaviour", {
skip_if(!dir.exists("api.twitter.com"))
expect_silent(get_retweeted_by(c("1399797349296197635", "1423714771384340481"), verbose = FALSE))
expect_output(get_retweeted_by(c("1399797349296197635", "1423714771384340481"), verbose = TRUE))
})
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-get_user_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

with_mock_api({
test_that("get_user_profile: expected behaviour", {
skip_if(!dir.exists("api.twitter.com"))
ori_test <- "../testdata/commtwitter/"
user_ids <- unique(bind_tweets(ori_test, verbose = FALSE)$author_id)[c(1,2,3)]
res <- get_user_profile(x = user_ids)
Expand All @@ -30,6 +31,7 @@ with_mock_api({

with_mock_api({
test_that("get_user_following: expected behaviour", {
skip_if(!dir.exists("api.twitter.com"))
ori_test <- "../testdata/commtwitter/"
user_ids <- unique(bind_tweets(ori_test, verbose = FALSE)$author_id)[c(1,2,3)]
res <- get_user_following(x = user_ids)
Expand All @@ -39,6 +41,7 @@ with_mock_api({

with_mock_api({
test_that("get_user_following: expected behaviour", {
skip_if(!dir.exists("api.twitter.com"))
ori_test <- "../testdata/commtwitter/"
user_ids <- unique(bind_tweets(ori_test, verbose = FALSE)$author_id)[c(1,2,3)]
res <- get_user_followers(x = user_ids)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-get_user_id.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

with_mock_api({
test_that("expected behavior, #153", {
skip_if(!dir.exists("api.twitter.com"))
usernames <- c("icahdq", "POTUS", "hadleywickhaM", "_R_Foundation", "adljfhjsd")
expect_error(get_user_id(usernames), NA) ## no error
expect_true(is.data.frame(get_user_id(usernames, all = TRUE)))
Expand Down
Loading

0 comments on commit b65656c

Please sign in to comment.