From 85a264466d703f11a2ec2607e557495e7efe4c48 Mon Sep 17 00:00:00 2001 From: Felix Torres Date: Wed, 27 Nov 2019 08:39:57 -0800 Subject: [PATCH 01/25] Write data dictionary. --- R/redcap-metadata-write.R | 163 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 R/redcap-metadata-write.R diff --git a/R/redcap-metadata-write.R b/R/redcap-metadata-write.R new file mode 100644 index 00000000..d7e1f1ad --- /dev/null +++ b/R/redcap-metadata-write.R @@ -0,0 +1,163 @@ +#' @title Write/Import records to a REDCap project +#' +#' @description This function uses REDCap's API to select and return data. +#' +#' @param ds The [base::data.frame()] to be imported into the REDCap project. +#' Required. +#' @param redcap_uri The URI (uniform resource identifier) of the REDCap +#' project. Required. +#' @param token The user-specific string that serves as the password for a +#' project. Required. +#' @param verbose A boolean value indicating if `message`s should be printed +#' to the R console during the operation. The verbose output might contain +#' sensitive information (*e.g.* PHI), so turn this off if the output might +#' be visible somewhere public. Optional. +#' @param config_options A list of options to pass to [httr::POST()] method +#' in the 'httr' package. See the details in [redcap_read_oneshot()] Optional. +#' +#' @return Currently, a list is returned with the following elements: +#' * `success`: A boolean value indicating if the operation was apparently +#' successful. +#' * `status_code`: The +#' [http status code](http://en.wikipedia.org/wiki/List_of_HTTP_status_codes) +#' of the operation. +#' * `outcome_message`: A human readable string indicating the operation's +#' outcome. +#' * `records_affected_count`: The number of records inserted or updated. +#' * `affected_ids`: The subject IDs of the inserted or updated records. +#' * `elapsed_seconds`: The duration of the function. +#' * `raw_text`: If an operation is NOT successful, the text returned by +#' REDCap. If an operation is successful, the `raw_text` is returned as an +#' empty string to save RAM. +#' +#' @details +#' Currently, the function doesn't modify any variable types to conform to +#' REDCap's supported variables. See [validate_for_write()] for a helper +#' function that checks for some common important conflicts. +#' +#' @author Will Beasley +#' +#' @references The official documentation can be found on the 'API Help Page' +#' and 'API Examples' pages on the REDCap wiki (*i.e.*, +#' https://community.projectredcap.org/articles/456/api-documentation.html and +#' https://community.projectredcap.org/articles/462/api-examples.html). +#' If you do not have an account for the wiki, please ask your campus REDCap +#' administrator to send you the static material. +#' +#' @examples +#' \dontrun{ +#' #Define some constants +#' uri <- "https://bbmc.ouhsc.edu/redcap/api/" +#' token <- "D70F9ACD1EDD6F151C6EA78683944E98" +#' +#' # Read the dataset for the first time. +#' result_read1 <- REDCapR::redcap_read_oneshot(redcap_uri=uri, token=token) +#' ds1 <- result_read1$data +#' ds1$telephone +#' +#' # Manipulate a field in the dataset in a VALID way +#' ds1$telephone <- paste0("(405) 321-000", seq_len(nrow(ds1))) +#' +#' ds1 <- ds1[1:3, ] +#' ds1$age <- NULL; ds1$bmi <- NULL #Drop the calculated fields before writing. +#' result_write <- REDCapR::redcap_write_oneshot(ds=ds1, redcap_uri=uri, token=token) +#' +#' # Read the dataset for the second time. +#' result_read2 <- REDCapR::redcap_read_oneshot(redcap_uri=uri, token=token) +#' ds2 <- result_read2$data +#' ds2$telephone +#' +#' # Manipulate a field in the dataset in an INVALID way. A US exchange can't be '111'. +#' ds1$telephone <- paste0("(405) 321-000", seq_len(nrow(ds1))) +#' +#' # This next line will throw an error. +#' result_write <- REDCapR::redcap_write_oneshot(ds=ds1, redcap_uri=uri, token=token) +#' result_write$raw_text +#' } + +#' @export +#' + +redcap_metadata_write <- function( + ds, + redcap_uri, + token, + verbose = TRUE, + config_options = NULL +) { + + # TODO: automatically convert boolean/logical class to integer/bit class + csv_elements <- NULL #This prevents the R CHECK NOTE: 'No visible binding for global variable Note in R CMD check'; Also see if( getRversion() >= "2.15.1" ) utils::globalVariables(names=c("csv_elements")) #http://stackoverflow.com/questions/8096313/no-visible-binding-for-global-variable-note-in-r-cmd-check; http://stackoverflow.com/questions/9439256/how-can-i-handle-r-cmd-check-no-visible-binding-for-global-variable-notes-when + + checkmate::assert_character(redcap_uri, any.missing=F, len=1, pattern="^.{1,}$") + checkmate::assert_character(token , any.missing=F, len=1, pattern="^.{1,}$") + + token <- sanitize_token(token) + verbose <- verbose_prepare(verbose) + + con <- base::textConnection( + object = "csv_elements", + open = "w", + local = TRUE + ) + utils::write.csv(ds, con, row.names = FALSE, na = "") + close(con) + + csv <- paste(csv_elements, collapse = "\n") + rm(csv_elements, con) + + post_body <- list( + token = token, + content = "metadata", + format = "csv", + type = "flat", + + #These next values separate the import from the export API call + #overwriteBehavior: + # *normal* - blank/empty values will be ignored [default]; + # *overwrite* - blank/empty values are valid and will overwrite data + + data = csv, + overwriteBehavior = "overwrite", + returnContent = "ids", + returnFormat = "csv" + ) + + # This is the important line that communicates with the REDCap server. + kernel <- kernel_api(redcap_uri, post_body, config_options) + + if (kernel$success) { + elements <- unlist(strsplit(kernel$raw_text, split="\\n")) + affected_ids <- as.character(elements[-1]) + records_affected_count <- length(affected_ids) + outcome_message <- sprintf( + "%s records were written to REDCap in %0.1f seconds.", + format(records_affected_count, big.mark = ",", scientific = FALSE, trim = TRUE), + kernel$elapsed_seconds + ) + + #If an operation is successful, the `raw_text` is no longer returned to save RAM. The content is not really necessary with httr's status message exposed. + kernel$raw_text <- "" + } else { #If the returned content wasn't recognized as valid IDs, then + affected_ids <- character(0) # Return an empty array + records_affected_count <- NA_integer_ + outcome_message <- sprintf( + "The REDCapR write/import operation was not successful. The error message was:\n%s", + kernel$raw_text + ) + } + + if (verbose) + message(outcome_message) + + list( + success = kernel$success, + status_code = kernel$status_code, + outcome_message = outcome_message, + records_affected_count = records_affected_count, + affected_ids = affected_ids, + elapsed_seconds = kernel$elapsed_seconds, + raw_text = kernel$raw_text + ) +} + From 514838b3f472a6a18c3b6188cd94ac4fda161254 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Sun, 19 Jan 2020 14:45:52 -0600 Subject: [PATCH 02/25] try to make code exclusions better behaved. Didn't work ref #263 --- R/redcap-metadata-read.R | 6 ++++-- R/redcap-next-free-record-name.R | 8 ++++++-- R/redcap-read.R | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/R/redcap-metadata-read.R b/R/redcap-metadata-read.R index 6aab6c0f..cf412030 100644 --- a/R/redcap-metadata-read.R +++ b/R/redcap-metadata-read.R @@ -129,7 +129,8 @@ redcap_metadata_read <- function( # to save RAM. The content is not really necessary with httr's status # message exposed. kernel$raw_text <- "" - } else { # nocov start + } else { + # nocov start # Override the 'success' determination from the http status code # and return an empty data.frame. kernel$success <- FALSE @@ -139,7 +140,8 @@ redcap_metadata_read <- function( kernel$status_code, kernel$raw_text ) - } # nocov stop + # nocov stop + } } else { ds <- data.frame() #Return an empty data.frame outcome_message <- sprintf( diff --git a/R/redcap-next-free-record-name.R b/R/redcap-next-free-record-name.R index efd1b692..ee386f8f 100644 --- a/R/redcap-next-free-record-name.R +++ b/R/redcap-next-free-record-name.R @@ -97,21 +97,25 @@ redcap_next_free_record_name <- function( value ) - } else { # nocov start + } else { + # nocov start value <- value_error outcome_message <- sprintf( "The REDCap determination of the next free record id failed. The http status code was %i. The 'raw_text' returned was '%s'.", kernel$status_code, kernel$raw_text ) + # nocov stop } } else { + # nocov start value <- value_error outcome_message <- sprintf( "The REDCap determination of the next free record id failed. The error message was:\n%s", kernel$raw_text ) - } # nocov stop + # nocov stop + } if (verbose) message(outcome_message) diff --git a/R/redcap-read.R b/R/redcap-read.R index 4cf5691f..cac27ad0 100644 --- a/R/redcap-read.R +++ b/R/redcap-read.R @@ -312,7 +312,8 @@ redcap_read <- function( ) if (continue_on_error) warning(error_message) - else stop(error_message) # nocov stop + else stop(error_message) + # nocov stop } lst_batch[[i]] <- read_result$data From c5fefa2d3a652d7380ec24c7919f8908e14cbae1 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Sun, 19 Jan 2020 14:50:56 -0600 Subject: [PATCH 03/25] avoid nocov start/stop ref #263 --- R/project-simple.R | 15 ++++++--------- R/redcap-metadata-read.R | 2 -- R/redcap-next-free-record-name.R | 4 ---- R/redcap-read-oneshot.R | 2 -- R/redcap-read.R | 2 -- 5 files changed, 6 insertions(+), 19 deletions(-) diff --git a/R/project-simple.R b/R/project-simple.R index 7254c11d..e2089217 100644 --- a/R/project-simple.R +++ b/R/project-simple.R @@ -4,20 +4,19 @@ populate_project_simple <- function(batch = FALSE) { checkmate::assert_logical(batch, any.missing = FALSE, len = 1) if (!requireNamespace("testthat")) { - # nocov start stop( "The function REDCapR:::populate_project_simple() cannot run if the ", "`testthat` package is not installed. Please install it and try again." ) - # nocov stop } # Declare the server & user information - uri <- "https://bbmc.ouhsc.edu/redcap/api/" - - # token <- "D96029BFCE8FFE76737BFC33C2BCC72E" #For `UnitTestPhiFree` account and the simple project (pid 27) on Vandy's test server. - # token <- "9A81268476645C4E5F03428B8AC3AA7B" #For `UnitTestPhiFree` account and the simple project (pid 153) - token <- "D70F9ACD1EDD6F151C6EA78683944E98" #For `UnitTestPhiFree` account and the simple project (pid 213) + credential <- REDCapR::retrieve_credential_local( + path_credential = system.file("misc/example.credentials", package="REDCapR"), + project_id = 213L + ) + uri <- credential$redcap_uri + token <- credential$token project <- REDCapR::redcap_project$new(redcap_uri = uri, token = token) path_in_simple <- system.file( @@ -72,12 +71,10 @@ populate_project_simple <- function(batch = FALSE) { } clear_project_simple <- function(verbose = TRUE) { if (!requireNamespace("testthat")) { - # nocov start stop( "The function REDCapR:::populate_project_simple() cannot run if the ", "`testthat` package is not installed. Please install it and try again." ) - # nocov stop } path_delete_test_record <- "https://bbmc.ouhsc.edu/redcap/plugins/redcapr/delete_redcapr_simple.php" diff --git a/R/redcap-metadata-read.R b/R/redcap-metadata-read.R index cf412030..b1b4bd63 100644 --- a/R/redcap-metadata-read.R +++ b/R/redcap-metadata-read.R @@ -130,7 +130,6 @@ redcap_metadata_read <- function( # message exposed. kernel$raw_text <- "" } else { - # nocov start # Override the 'success' determination from the http status code # and return an empty data.frame. kernel$success <- FALSE @@ -140,7 +139,6 @@ redcap_metadata_read <- function( kernel$status_code, kernel$raw_text ) - # nocov stop } } else { ds <- data.frame() #Return an empty data.frame diff --git a/R/redcap-next-free-record-name.R b/R/redcap-next-free-record-name.R index ee386f8f..f431cf96 100644 --- a/R/redcap-next-free-record-name.R +++ b/R/redcap-next-free-record-name.R @@ -98,23 +98,19 @@ redcap_next_free_record_name <- function( ) } else { - # nocov start value <- value_error outcome_message <- sprintf( "The REDCap determination of the next free record id failed. The http status code was %i. The 'raw_text' returned was '%s'.", kernel$status_code, kernel$raw_text ) - # nocov stop } } else { - # nocov start value <- value_error outcome_message <- sprintf( "The REDCap determination of the next free record id failed. The error message was:\n%s", kernel$raw_text ) - # nocov stop } if (verbose) diff --git a/R/redcap-read-oneshot.R b/R/redcap-read-oneshot.R index 1c8d9f53..5418920d 100644 --- a/R/redcap-read-oneshot.R +++ b/R/redcap-read-oneshot.R @@ -284,7 +284,6 @@ redcap_read_oneshot <- function( } else { # ds doesn't exist as a data.frame. # Override the 'success' determination from the http status code. # and return an empty data.frame. - # nocov start kernel$success <- FALSE ds <- data.frame() outcome_message <- sprintf( @@ -292,7 +291,6 @@ redcap_read_oneshot <- function( kernel$status_code, kernel$raw_text ) - # nocov stop } } else { # kernel fails ds <- data.frame() #Return an empty data.frame diff --git a/R/redcap-read.R b/R/redcap-read.R index cac27ad0..831e607f 100644 --- a/R/redcap-read.R +++ b/R/redcap-read.R @@ -297,7 +297,6 @@ redcap_read <- function( lst_outcome_message[[i]] <- read_result$outcome_message if (!read_result$success) { - # nocov start error_message <- sprintf( "The `redcap_read()` call failed on iteration %i.", i @@ -313,7 +312,6 @@ redcap_read <- function( if (continue_on_error) warning(error_message) else stop(error_message) - # nocov stop } lst_batch[[i]] <- read_result$data From e7bb71f106655a831142d54f11dcdb98fb12690c Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Sun, 19 Jan 2020 16:48:58 -0600 Subject: [PATCH 04/25] fix codecov stop/end should have been 'end'. It was messing up the covr call at the end of travis ref #263 --- R/project-simple.R | 6 +++++- R/redcap-metadata-read.R | 4 ++-- R/redcap-next-free-record-name.R | 4 ++++ R/redcap-read-oneshot.R | 2 ++ R/redcap-read.R | 2 ++ 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/R/project-simple.R b/R/project-simple.R index e2089217..c793d8e6 100644 --- a/R/project-simple.R +++ b/R/project-simple.R @@ -4,10 +4,12 @@ populate_project_simple <- function(batch = FALSE) { checkmate::assert_logical(batch, any.missing = FALSE, len = 1) if (!requireNamespace("testthat")) { + # nocov start stop( "The function REDCapR:::populate_project_simple() cannot run if the ", "`testthat` package is not installed. Please install it and try again." ) + # nocov end } # Declare the server & user information @@ -71,10 +73,12 @@ populate_project_simple <- function(batch = FALSE) { } clear_project_simple <- function(verbose = TRUE) { if (!requireNamespace("testthat")) { + # nocov start stop( "The function REDCapR:::populate_project_simple() cannot run if the ", "`testthat` package is not installed. Please install it and try again." ) + # nocov end } path_delete_test_record <- "https://bbmc.ouhsc.edu/redcap/plugins/redcapr/delete_redcapr_simple.php" @@ -103,7 +107,7 @@ clean_start_simple <- function(batch = FALSE, delay_in_seconds = 1) { "The function REDCapR:::populate_project_simple() cannot run if the ", "`testthat` package is not installed. Please install it and try again." ) - # nocov stop + # nocov end } testthat::expect_message( clear_result <- clear_project_simple(), diff --git a/R/redcap-metadata-read.R b/R/redcap-metadata-read.R index b1b4bd63..b25e7842 100644 --- a/R/redcap-metadata-read.R +++ b/R/redcap-metadata-read.R @@ -129,7 +129,7 @@ redcap_metadata_read <- function( # to save RAM. The content is not really necessary with httr's status # message exposed. kernel$raw_text <- "" - } else { + } else { # nocov start # Override the 'success' determination from the http status code # and return an empty data.frame. kernel$success <- FALSE @@ -139,7 +139,7 @@ redcap_metadata_read <- function( kernel$status_code, kernel$raw_text ) - } + } # nocov end } else { ds <- data.frame() #Return an empty data.frame outcome_message <- sprintf( diff --git a/R/redcap-next-free-record-name.R b/R/redcap-next-free-record-name.R index f431cf96..a5332458 100644 --- a/R/redcap-next-free-record-name.R +++ b/R/redcap-next-free-record-name.R @@ -98,19 +98,23 @@ redcap_next_free_record_name <- function( ) } else { + # nocov start value <- value_error outcome_message <- sprintf( "The REDCap determination of the next free record id failed. The http status code was %i. The 'raw_text' returned was '%s'.", kernel$status_code, kernel$raw_text ) + # nocov end } } else { + # nocov start value <- value_error outcome_message <- sprintf( "The REDCap determination of the next free record id failed. The error message was:\n%s", kernel$raw_text ) + # nocov end } if (verbose) diff --git a/R/redcap-read-oneshot.R b/R/redcap-read-oneshot.R index 5418920d..1d533278 100644 --- a/R/redcap-read-oneshot.R +++ b/R/redcap-read-oneshot.R @@ -284,6 +284,7 @@ redcap_read_oneshot <- function( } else { # ds doesn't exist as a data.frame. # Override the 'success' determination from the http status code. # and return an empty data.frame. + # nocov start kernel$success <- FALSE ds <- data.frame() outcome_message <- sprintf( @@ -291,6 +292,7 @@ redcap_read_oneshot <- function( kernel$status_code, kernel$raw_text ) + # nocov end } } else { # kernel fails ds <- data.frame() #Return an empty data.frame diff --git a/R/redcap-read.R b/R/redcap-read.R index 831e607f..ad5613da 100644 --- a/R/redcap-read.R +++ b/R/redcap-read.R @@ -297,6 +297,7 @@ redcap_read <- function( lst_outcome_message[[i]] <- read_result$outcome_message if (!read_result$success) { + # nocov start error_message <- sprintf( "The `redcap_read()` call failed on iteration %i.", i @@ -312,6 +313,7 @@ redcap_read <- function( if (continue_on_error) warning(error_message) else stop(error_message) + # nocov end } lst_batch[[i]] <- read_result$data From dcb6db919c4d1e0b54de463861a2ecf64a6b99e9 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Sun, 19 Jan 2020 17:10:37 -0600 Subject: [PATCH 05/25] retrieve tokens from file --- tests/manual/test-could-not-connect-rate.R | 11 +++++++---- tests/manual/test-stress-test-serial.R | 9 +++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/manual/test-could-not-connect-rate.R b/tests/manual/test-could-not-connect-rate.R index d657ed39..e5d02640 100644 --- a/tests/manual/test-could-not-connect-rate.R +++ b/tests/manual/test-could-not-connect-rate.R @@ -2,10 +2,13 @@ library(testthat) context("Estimate 'Could Not Connect' Rate.") -uri <- "https://bbmc.ouhsc.edu/redcap/api/" -# uri <- "https://bbmc.ouhsc.edu/redcap/api/api2.php" -# uri <- "https://bbmc.ouhsc.edu/redcap/api/dx.php" -token <- "9A81268476645C4E5F03428B8AC3AA7B" #For `UnitTestPhiFree` account on pid=153. +# Declare the server & user information +credential <- REDCapR::retrieve_credential_local( + path_credential = system.file("misc/example.credentials", package="REDCapR"), + project_id = 153L +) +uri <- credential$redcap_uri +token <- credential$token record_read_count <- 2000L record_write_count <- 200L diff --git a/tests/manual/test-stress-test-serial.R b/tests/manual/test-stress-test-serial.R index 598558f2..d4f102e8 100644 --- a/tests/manual/test-stress-test-serial.R +++ b/tests/manual/test-stress-test-serial.R @@ -2,8 +2,13 @@ library(testthat) context("Stress Test - Serial") -uri <- "https://bbmc.ouhsc.edu/redcap/api/" -token <- "9A81268476645C4E5F03428B8AC3AA7B" #For `UnitTestPhiFree` account on pid=153. +# Declare the server & user information +credential <- REDCapR::retrieve_credential_local( + path_credential = system.file("misc/example.credentials", package="REDCapR"), + project_id = 153L +) +uri <- credential$redcap_uri +token <- credential$token read_count <- 2000L file_count <- 200L From 2cf18463e5088dd86648d2d0a9262160625c3f5e Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Sun, 19 Jan 2020 20:05:08 -0600 Subject: [PATCH 06/25] prepare for metadata write ref #274 --- inst/misc/bad.credentials | 2 +- inst/misc/example.credentials | 3 ++- inst/misc/out-of-order.credentials | 2 +- tests/testthat/test-metadata-read.R | 2 +- tests/testthat/test-metadata-utilities.R | 2 +- tests/testthat/test-retrieve-credential-local.R | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/inst/misc/bad.credentials b/inst/misc/bad.credentials index 0c888c0f..418e24bb 100644 --- a/inst/misc/bad.credentials +++ b/inst/misc/bad.credentials @@ -5,4 +5,4 @@ # redcap_uri,username,project_id,token,comment "http://bbmc.ouhsc.edu/redcap/api/","myusername","153","9A81268476645C4E5F03428B8A","simple static (read-only) test project" -"https://bbmc.ouhsc.edu/redcap/api/","myusername","212","D70F9ACD1EDD6F151C6EA78683944E98","simple write test project" +"https://bbmc.ouhsc.edu/redcap/api/","myusername","212","D70F9ACD1EDD6F151C6EA78683944E98","simple write data" diff --git a/inst/misc/example.credentials b/inst/misc/example.credentials index 8ba4b54f..722d8c5b 100644 --- a/inst/misc/example.credentials +++ b/inst/misc/example.credentials @@ -6,7 +6,7 @@ redcap_uri,username,project_id,token,comment "https://bbmc.ouhsc.edu/redcap/api/","myusername","153","9A81268476645C4E5F03428B8AC3AA7B","simple static (read-only) test project" "https://bbmc.ouhsc.edu/redcap/api/","myusername","212","0434F0E9CF53ED0587847AB6E51DE762","longitudinal (read-only) ARM test project" -"https://bbmc.ouhsc.edu/redcap/api/","myusername","213","D70F9ACD1EDD6F151C6EA78683944E98","simple write test project" +"https://bbmc.ouhsc.edu/redcap/api/","myusername","213","D70F9ACD1EDD6F151C6EA78683944E98","simple write data" "https://bbmc.ouhsc.edu/redcap/api/","myusername","268","D72C6485B52FE9F75D27B696977FBA43","Russian Characters" "https://bbmc.ouhsc.edu/redcap/api/","myusername","690","7668169F66720113E844491FFDB65273","Empty rows" "https://bbmc.ouhsc.edu/redcap/api/","myusername","691","814BA96077C9864D0FFDCABD2778814F","Single column" @@ -19,3 +19,4 @@ redcap_uri,username,project_id,token,comment "https://bbmc.ouhsc.edu/redcap/api/","myusername","1396","14A41597332864D74460CBBF52EE49A6","potentially problematic values" "https://bbmc.ouhsc.edu/redcap/api/","myusername","1400","F187271FC6FD72C3BFCE37990A6BF6A7","Repeating Instruments" "https://bbmc.ouhsc.edu/redcap/api/","myusername","1425","221E86DABFEEA233067C6889991B7FBB","Potentially problematic dictionary" +"https://bbmc.ouhsc.edu/redcap/api/","myusername","1490","457C24AB91B7FCF5B1A7DA67E70E24C7","simple write metadata" diff --git a/inst/misc/out-of-order.credentials b/inst/misc/out-of-order.credentials index b8b5a1a3..09fa04f7 100644 --- a/inst/misc/out-of-order.credentials +++ b/inst/misc/out-of-order.credentials @@ -5,4 +5,4 @@ # token,comment,project_id,redcap_uri,username "https://bbmc.ouhsc.edu/redcap/api/","myusername","153","9A81268476645C4E5F03428B8AC3AA7B","simple static (read-only) test project" -"https://bbmc.ouhsc.edu/redcap/api/","myusername","212","D70F9ACD1EDD6F151C6EA78683944E98","simple write test project" +"https://bbmc.ouhsc.edu/redcap/api/","myusername","212","D70F9ACD1EDD6F151C6EA78683944E98","simple write data" diff --git a/tests/testthat/test-metadata-read.R b/tests/testthat/test-metadata-read.R index ca8eb02e..4a6669d3 100644 --- a/tests/testthat/test-metadata-read.R +++ b/tests/testthat/test-metadata-read.R @@ -13,7 +13,7 @@ credential_problem <- REDCapR::retrieve_credential_local( project_id = 1425 ) -test_that("Metadata Smoke Test", { +test_that("Metadata Read Smoke Test", { testthat::skip_on_cran() expect_message( returned_object <- redcap_metadata_read(redcap_uri=credential$redcap_uri, token=credential$token) diff --git a/tests/testthat/test-metadata-utilities.R b/tests/testthat/test-metadata-utilities.R index c122e7bb..121b479f 100644 --- a/tests/testthat/test-metadata-utilities.R +++ b/tests/testthat/test-metadata-utilities.R @@ -14,7 +14,7 @@ test_that("Named Captures", { expect_equal(dsBoxes, expected=dsExpected, label="The returned data.frame should be correct") #dput(dsBoxes) }) -test_that("Named Captures", { +test_that("checkbox choices", { pattern_checkboxes <- "(?<=\\A| \\| )(?\\d{1,}), (?