Skip to content

Commit

Permalink
change default to all arms
Browse files Browse the repository at this point in the history
ref #482
  • Loading branch information
wibeasley committed May 26, 2023
1 parent f3fcaea commit 28faddd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
7 changes: 4 additions & 3 deletions R/redcap-event-instruments.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#' Required.
#' @param token The user-specific string that serves as the password for a
#' project. Required.
#' @param arms A character string of arms to retrieve. (Default: '1')
#' @param arms A character string of arms to retrieve.
#' Defaults to all arms of the project.
#' @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
Expand Down Expand Up @@ -69,8 +70,8 @@
#' token_2 <- "0434F0E9CF53ED0587847AB6E51DE762" # pid 212
#' REDCapR::redcap_arm_export(redcap_uri=uri, token=token_2)$data
#' REDCapR::redcap_event_instruments(redcap_uri=uri, token=token_2)$data
#' REDCapR::redcap_event_instruments(redcap_uri=uri, token=token_2, arms = "2")$data
#' REDCapR::redcap_event_instruments(redcap_uri=uri, token=token_2, arms = c("1", "2"))$data
#' REDCapR::redcap_event_instruments(redcap_uri=uri, token=token_2, arms = "2")$data
#'
#' # Classic project (without arms) throws an error
#' token_3 <- "9A81268476645C4E5F03428B8AC3AA7B" # pid 153
Expand All @@ -82,7 +83,7 @@
redcap_event_instruments <- function(
redcap_uri,
token,
arms = c("1"),
arms = NULL,
verbose = TRUE,
config_options = NULL,
handle_httr = NULL
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/test-event-instruments.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ test_that("2-arms-retrieve-both-arms", {
expect_match( returned_object_explicit$outcome_message, regexp=expected_outcome_message, perl=TRUE)
expect_true( returned_object_explicit$success)
expect_s3_class(returned_object_explicit$data, "tbl")

returned_object_default <-
redcap_event_instruments(
redcap_uri = credential$redcap_uri,
token = credential$token,
verbose = FALSE
)

expect_equal( returned_object_default$data, expected=expected_data_frame, label="The returned data.frame should be correct", ignore_attr = TRUE) # dput(returned_object$data)
expect_equal( returned_object_default$status_code, expected=200L)
expect_equal( returned_object_default$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object$raw_text)
expect_match( returned_object_default$outcome_message, regexp=expected_outcome_message, perl=TRUE)
expect_true( returned_object_default$success)
expect_s3_class(returned_object_default$data, "tbl")
})
test_that("2-arms-retrieve-only-arm-1", {
testthat::skip_on_cran()
Expand All @@ -48,6 +62,7 @@ test_that("2-arms-retrieve-only-arm-1", {
redcap_event_instruments(
redcap_uri = credential$redcap_uri,
token = credential$token,
arms = "1",
verbose = FALSE
)

Expand Down

0 comments on commit 28faddd

Please sign in to comment.