Skip to content

Commit

Permalink
test multiple projects
Browse files Browse the repository at this point in the history
ref #410
  • Loading branch information
wibeasley committed Aug 25, 2022
1 parent 9a9e4c3 commit 661e57e
Show file tree
Hide file tree
Showing 2 changed files with 168 additions and 0 deletions.
132 changes: 132 additions & 0 deletions inst/test-data/specific-redcapr/project-info-read/all-test-projects.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
structure(list(project_id = c(153L, 212L, 213L, 268L, 690L, 691L,
753L, 817L, 977L, 998L, 999L, 1396L, 1400L, 1425L, 1490L, 2545L,
2545L, 2593L, 2597L, 2603L, 2626L, 2627L, 2629L, 2630L, 2631L,
2632L, 2634L, 3003L), project_title = c("REDCapR Target Simple Static -see https://github.com/OuhscBbmc/REDCapR",
"REDCapR Target Longitudinal Arm -see https://github.com/OuhscBbmc/REDCapR",
"REDCapR Target Simple -Write Data", "REDCapR Russian -see https://github.com/OuhscBbmc/REDCapR",
"REDCapR Target Empty Rows -see https://github.com/OuhscBbmc/REDCapR",
"REDCapR Target Empty Columns -see https://github.com/OuhscBbmc/REDCapR",
"REDCapR Target Super-wide -see https://github.com/OuhscBbmc/REDCapR",
"REDCapR Target Survey Static -see https://github.com/OuhscBbmc/REDCapR",
"REDCap Target Fake Clinical Trial", "REDCapR Target -nonumeric record_id",
"REDCapR Target DAG -see https://github.com/OuhscBbmc/REDCapR",
"REDCapR Problematic values", "REDCapR Repeating Instruments --See https://github.com/OuhscBbmc/REDCapR",
"REDCapR Problematic dictionary", "REDCapR Target Simple -Write Metadata",
"REDCapR Target DAG -Write Data -see https://github.com/OuhscBbmc/REDCapR",
"REDCapR Target DAG -Write Data -see https://github.com/OuhscBbmc/REDCapR",
"REDCapR Target Super-wide 2 -see https://github.com/OuhscBbmc/REDCapR",
"REDCapR superwide 3", "REDCapR Repeating Instruments Sparse",
"REDCapR Delete Single Arm", "REDCapR Delete Multiple Arms",
"REDCapR Longitudinal Single Arm", "REDCapR Decimal Commas and Dots",
"REDCapR Decimal Comma", "REDCapR Decimal Dots", "REDCapR Validation Types",
"REDCapR Target Simple with Gray Form Status --see https://github.com/OuhscBbmc/REDCapR"
), creation_time = structure(c(1385762300, 1409508475, 1409510046,
1424542707, 1503371677, 1503372285, 1512140287, 1520372784, 1535128221,
1536708074, 1536717011, 1570739027, 1571112561, 1573579416, 1579464868,
1632500924, 1632500924, 1635560455, 1635866052, 1636077368, 1637557792,
1637557976, 1637874534, 1637941852, 1637959298, 1637959358, 1638248591,
1660433618), tzone = "America/Chicago", class = c("POSIXct",
"POSIXt")), production_time = structure(c(NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), tzone = "America/Chicago", class = c("POSIXct",
"POSIXt")), in_production = c(FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE), project_language = c("English",
"English", "English", "English", "English", "English", "English",
"English", "English", "English", "English", "English", "English",
"English", "English", "English", "English", "English", "English",
"English", "English", "English", "English", "English", "English",
"English", "English", "English"), purpose = c(0L, 0L, 0L, 0L,
0L, 0L, 4L, 4L, 0L, 4L, 0L, 1L, 4L, 4L, 0L, 3L, 3L, 4L, 4L, 4L,
4L, 4L, 4L, 3L, 3L, 3L, 3L, 0L), purpose_other = c(NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, "Testing REDCapR API library (in R)",
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA
), project_notes = c(NA, NA, "see https://github.com/OuhscBbmc/REDCapR",
NA, NA, NA, NA, NA, "Generated & contributed by Peter Higgins at University of Michigan School of Medicine",
"Helps test functions when the record name is not numeric", NA,
"Contains values that might create problems for the API recipient",
"Repeating instruments", "Has variables or descriptions that might cause problems with the API",
"see https://github.com/OuhscBbmc/REDCapR", NA, NA, "Another very wide dataset. Supports https://github.com/OuhscBbmc/REDCapR/issues/335",
"REDCapR -- see https://github.com/OuhscBbmc/REDCapR/issues/335",
"Repeating instruments See https://github.com/OuhscBbmc/REDCapR",
"REDCapR Test Suite: delete records from a single-arm project",
"REDCapR Test Suite: delete records from a multiple-arm project",
"Longitudinal project with only one arm", NA, NA, NA, "REDCapR using Validation Types",
"Created for \nhttps://github.com/OuhscBbmc/REDCapR/issues/386 & https://github.com/OuhscBbmc/REDCapR/pull/389"
), custom_record_label = c(NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA), secondary_unique_field = c(NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA), is_longitudinal = c(FALSE, TRUE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE), has_repeating_instruments_or_events = c(FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE),
surveys_enabled = c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE), scheduling_enabled = c(FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE
), record_autonumbering_enabled = c(TRUE, FALSE, TRUE, FALSE,
TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE,
TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE), randomization_enabled = c(FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE
), ddp_enabled = c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE), project_irb_number = c(NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), project_grant_number = c(NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), project_pi_firstname = c(NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), project_pi_lastname = c(NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), display_today_now_button = c(TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE), missing_data_codes = c(NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), external_modules = c("cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks",
"cross_project_piping,date_validation_action_tags,form_status_tweaks"
), bypass_branching_erase_field_prompt = c(FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE)), row.names = c(NA,
-28L), class = c("tbl_df", "tbl", "data.frame"))
36 changes: 36 additions & 0 deletions tests/testthat/test-project-info-read.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,42 @@ test_that("simple", {
expect_true( returned_object$success)
})

test_that("all-test-projects", {
testthat::skip_on_cran()
path_expected <- "test-data/specific-redcapr/project-info-read/all-test-projects.R"
expected_outcome_message <- "\\d+ rows were read from REDCap in \\d+(\\.\\d+\\W|\\W)seconds\\."

server_locale <- readr::locale(tz = "America/Chicago")

expect_message(
regexp = expected_outcome_message,
returned_object <-
system.file("misc/example.credentials", package = "REDCapR") |>
readr::read_csv(
comment = "#",
col_select = c(redcap_uri, token),
col_types = readr::cols(.default = readr::col_character()),
) |>
dplyr::filter(32L == nchar(token)) |>
purrr::pmap_dfr(
REDCapR::redcap_project_info_read,
locale = server_locale
)
)

if (update_expectation) {
attr(returned_object, which = "problems") <- NULL
save_expected(returned_object$data, path_expected)
}
expected_data_frame <- retrieve_expected(path_expected)

expect_equal(returned_object$data, expected=expected_data_frame, label="The returned data.frame should be correct", ignore_attr = TRUE) # dput(returned_object$data)
expect_match(as.character(returned_object$status_code), regexp="200", perl=TRUE)
expect_match(returned_object$raw_text, regexp="", perl=TRUE) # dput(returned_object$raw_text)
expect_match(returned_object$outcome_message, regexp=expected_outcome_message, perl=TRUE)
expect_true( all(returned_object$success))
})

test_that("chicago", {
testthat::skip_on_cran()
path_expected <- "test-data/specific-redcapr/project-info-read/chicago.R"
Expand Down

0 comments on commit 661e57e

Please sign in to comment.