Skip to content

Commit

Permalink
testing more superwide datasets
Browse files Browse the repository at this point in the history
ref #400
  • Loading branch information
wibeasley committed Jul 22, 2022
1 parent ef3e353 commit da15592
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 14 deletions.
9 changes: 4 additions & 5 deletions inst/test-data/super-wide-3/generate-dictionary.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ REDCapR::redcap_write(
batch_size = 1
)

# readr::write_csv(ds, "inst/test-data/super-wide-3/super-wide-3-dictionary.csv")
REDCapR:::redcap_read_oneshot_eav(
redcap_uri = credential$redcap_uri,
token = credential$token
)$data
# REDCapR:::redcap_read_oneshot_eav(
# redcap_uri = credential$redcap_uri,
# token = credential$token
# )$data
84 changes: 75 additions & 9 deletions tests/testthat/test-read-superwide.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
library(testthat)

credential <- retrieve_credential_testing(753L)
credential_1 <- retrieve_credential_testing(753L)
credential_2 <- retrieve_credential_testing(2593L)
credential_3 <- retrieve_credential_testing(2597L)

test_that("smoke test", {
test_that("smoke test -superwide 1", {
testthat::skip_on_cran()
expect_message(
returned_object <- redcap_read_oneshot(redcap_uri=credential$redcap_uri, token=credential$token)
returned_object <- redcap_read_oneshot(redcap_uri=credential_1$redcap_uri, token=credential_1$token)
)
})
test_that("smoke test -superwide 2", {
testthat::skip_on_cran()
expect_message(
returned_object <- redcap_read_oneshot(redcap_uri=credential_2$redcap_uri, token=credential_2$token)
)
})
test_that("smoke test -superwide 3", {
testthat::skip_on_cran()
expect_message(
returned_object <- redcap_read_oneshot(redcap_uri=credential_3$redcap_uri, token=credential_3$token)
)
})

test_that("correct dimensions -oneshot", {
test_that("correct dimensions -superwide 1 -oneshot", {
testthat::skip_on_cran()
expected_outcome_message <- "2 records and 3,004 columns were read from REDCap in \\d+(\\.\\d+\\W|\\W)seconds\\."

Expand All @@ -18,7 +32,7 @@ test_that("correct dimensions -oneshot", {

expect_message(
regexp = expected_outcome_message,
returned_object <- redcap_read_oneshot(redcap_uri=credential$redcap_uri, token=credential$token)
returned_object <- redcap_read_oneshot(redcap_uri=credential_1$redcap_uri, token=credential_1$token)
)

expect_equal(nrow(returned_object$data), expected=expected_row_count) # dput(returned_object$data)
Expand All @@ -33,8 +47,7 @@ test_that("correct dimensions -oneshot", {
expect_match(returned_object$outcome_message, regexp=expected_outcome_message, perl=TRUE)
expect_true(returned_object$success)
})

test_that("correct dimensions -batch", {
test_that("correct dimensions -superwide 1 -batch", {
testthat::skip_on_cran()
expected_outcome_message <- "2 records and 3,004 columns were read from REDCap in \\d+(\\.\\d+\\W|\\W)seconds\\."

Expand All @@ -43,7 +56,7 @@ test_that("correct dimensions -batch", {

expect_message(
regexp = expected_outcome_message,
returned_object <- redcap_read(redcap_uri=credential$redcap_uri, token=credential$token)
returned_object <- redcap_read(redcap_uri=credential_1$redcap_uri, token=credential_1$token)
)

expect_equal(nrow(returned_object$data), expected=expected_row_count) # dput(returned_object$data)
Expand All @@ -58,4 +71,57 @@ test_that("correct dimensions -batch", {
expect_match( returned_object$outcome_messages, regexp=expected_outcome_message, perl=TRUE)
})

rm(credential)
# test_that("correct dimensions -superwide 3 -oneshot", {
# testthat::skip_on_cran()
#
# expected_outcome_message <- "20 records and 17,502 columns were read from REDCap in \\d+(\\.\\d+\\W|\\W)seconds\\."
#
# expected_row_count <- 20L
# expected_column_count <- 17502L
#
# meta <- redcap_metadata_read(credential_3$redcap_uri, credential_3$token)
# read <- redcap_read_oneshot( credential_3$redcap_uri, credential_3$token)
#
#
# expect_message(
# regexp = expected_outcome_message,
# returned_object <- redcap_read_oneshot(redcap_uri=credential_3$redcap_uri, token=credential_3$token)
# )
#
# expect_equal(nrow(returned_object$data), expected=expected_row_count) # dput(returned_object$data)
# expect_equal(ncol(returned_object$data), expected=expected_column_count)
# expect_false(any(is.na(returned_object$data)))
#
# expect_equal(returned_object$status_code, expected=200L)
# expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object$raw_text)
# expect_true(returned_object$records_collapsed=="", "A subset of records was not requested.")
# expect_true(returned_object$fields_collapsed=="", "A subset of fields was not requested.")
# expect_true(returned_object$filter_logic=="", "A filter was not specified.")
# expect_match(returned_object$outcome_message, regexp=expected_outcome_message, perl=TRUE)
# expect_true(returned_object$success)
# })
# test_that("correct dimensions -superwide 3 -batch", {
# testthat::skip_on_cran()
# expected_outcome_message <- "20 records and 17,502 columns were read from REDCap in \\d+(\\.\\d+\\W|\\W)seconds\\."
#
# expected_row_count <- 20L
# expected_column_count <- 17502L
#
# expect_message(
# regexp = expected_outcome_message,
# returned_object <- redcap_read(redcap_uri=credential_3$redcap_uri, token=credential_3$token)
# )
#
# expect_equal(nrow(returned_object$data), expected=expected_row_count) # dput(returned_object$data)
# expect_equal(ncol(returned_object$data), expected=expected_column_count)
# expect_false(any(is.na(returned_object$data)))
#
# expect_true( returned_object$success)
# expect_match( returned_object$status_codes, regexp="200", perl=TRUE)
# expect_true( returned_object$records_collapsed=="", "A subset of records was not requested.")
# expect_true( returned_object$fields_collapsed=="", "A subset of fields was not requested.")
# expect_true( returned_object$filter_logic=="", "A filter was not specified.")
# expect_match( returned_object$outcome_messages, regexp=expected_outcome_message, perl=TRUE)
# })

rm(credential_1)

0 comments on commit da15592

Please sign in to comment.