From 6c5ca601e3528ed527b8b4bb849a76f94158b24f Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Wed, 16 Oct 2024 18:10:11 -0500 Subject: [PATCH 01/21] moving arm & event ref #542 --- .../arm-multiple-delete}/arm.csv | 0 .../arm-multiple-delete}/event.csv | 0 tests/testthat/test-arm-export.R | 2 +- tests/testthat/test-event-read.R | 2 +- 4 files changed, 2 insertions(+), 2 deletions(-) rename inst/test-data/{delete-multiple-arm => projects/arm-multiple-delete}/arm.csv (100%) rename inst/test-data/{delete-multiple-arm => projects/arm-multiple-delete}/event.csv (100%) diff --git a/inst/test-data/delete-multiple-arm/arm.csv b/inst/test-data/projects/arm-multiple-delete/arm.csv similarity index 100% rename from inst/test-data/delete-multiple-arm/arm.csv rename to inst/test-data/projects/arm-multiple-delete/arm.csv diff --git a/inst/test-data/delete-multiple-arm/event.csv b/inst/test-data/projects/arm-multiple-delete/event.csv similarity index 100% rename from inst/test-data/delete-multiple-arm/event.csv rename to inst/test-data/projects/arm-multiple-delete/event.csv diff --git a/tests/testthat/test-arm-export.R b/tests/testthat/test-arm-export.R index f618d72e..314851b2 100644 --- a/tests/testthat/test-arm-export.R +++ b/tests/testthat/test-arm-export.R @@ -27,7 +27,7 @@ test_that("delete-multiple-arm", { testthat::skip_on_cran() credential <- retrieve_credential_testing("arm-multiple-delete") - path_expected <- "test-data/delete-multiple-arm/arm.csv" + path_expected <- "test-data/projects/arm-multiple-delete/arm.csv" expected_data_frame <- read_arms(path_expected) # start_clean_result <- REDCapR:::clean_start_delete_single_arm() diff --git a/tests/testthat/test-event-read.R b/tests/testthat/test-event-read.R index 9033a5ab..adcc7dbd 100644 --- a/tests/testthat/test-event-read.R +++ b/tests/testthat/test-event-read.R @@ -110,7 +110,7 @@ test_that("delete-multiple-arm", { testthat::skip_on_cran() credential <- retrieve_credential_testing("arm-multiple-delete") - path_expected <- "test-data/delete-multiple-arm/event.csv" + path_expected <- "test-data/projects/arm-multiple-delete/event.csv" expected_data_frame <- retrieve_expected_events(path_expected) expected_outcome_message <- "The list of events was retrieved from the REDCap project in \\d+(\\.\\d+\\W|\\W)seconds\\." From c2a08ca15bbc0f4f436453c52e5d4d8a75e27acd Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Wed, 16 Oct 2024 18:30:12 -0500 Subject: [PATCH 02/21] curly brackets --- tests/spelling.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/spelling.R b/tests/spelling.R index d1c907c2..177df0fa 100644 --- a/tests/spelling.R +++ b/tests/spelling.R @@ -1,6 +1,7 @@ -if (requireNamespace("spelling", quietly = TRUE)) +if (requireNamespace("spelling", quietly = TRUE)) { spelling::spell_check_test( vignettes = TRUE, error = FALSE, skip_on_cran = TRUE ) +} From 8158aa93a92115a770b61072dda8bead7822d48c Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Wed, 16 Oct 2024 18:31:36 -0500 Subject: [PATCH 03/21] tidy --- tests/testthat/test-validate-no-logical.R | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/testthat/test-validate-no-logical.R b/tests/testthat/test-validate-no-logical.R index 065c305f..ca504a0f 100644 --- a/tests/testthat/test-validate-no-logical.R +++ b/tests/testthat/test-validate-no-logical.R @@ -31,11 +31,6 @@ test_that("validate_no_logical -concern dataset", { }) # ---- redcap-repeat-instance -------------------------------------------------- -# credential <- REDCapR::retrieve_credential_local( -# path_credential = system.file("misc/dev-2.credentials", package = "REDCapR"), -# project_id = 1400 -# ) - test_that("repeat-instance: no column", { ds <- validate_repeat_instance(mtcars) expect_equal(object = nrow(ds), expected = 0) From 294bec5d3bbc37c787d3e44103e973d0fb772c3c Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Wed, 16 Oct 2024 18:35:39 -0500 Subject: [PATCH 04/21] tidy --- R/retrieve-credential.R | 3 --- 1 file changed, 3 deletions(-) diff --git a/R/retrieve-credential.R b/R/retrieve-credential.R index 01c9932f..bbca2582 100644 --- a/R/retrieve-credential.R +++ b/R/retrieve-credential.R @@ -258,9 +258,6 @@ credential_local_validation <- function( } } -# system.file("misc/vignette.css", package="REDCapR") -# system.file("misc/dev-2.credentials", package="REDCapR") - #' @export create_credential_local <- function(path_credential) { path_source <- system.file( From 96984eedee528b0ca95a66402ac71b9b4a9597f2 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Wed, 16 Oct 2024 20:47:10 -0500 Subject: [PATCH 05/21] consolidate arm-single data ref #542 --- R/project-delete-single-arm.R | 3 ++- .../data.csv => projects/arm-single-delete/data-old.csv} | 4 ---- inst/test-data/projects/arm-single-delete/data.csv | 4 ++++ 3 files changed, 6 insertions(+), 5 deletions(-) rename inst/test-data/{delete-single-arm/data.csv => projects/arm-single-delete/data-old.csv} (82%) diff --git a/R/project-delete-single-arm.R b/R/project-delete-single-arm.R index 0d15778f..59ba691a 100644 --- a/R/project-delete-single-arm.R +++ b/R/project-delete-single-arm.R @@ -17,7 +17,8 @@ populate_project_delete_single_arm <- function(verbose = FALSE) { token = credential$token ) path_in <- system.file( - "test-data/delete-single-arm/data.csv", + "test-data/projects/arm-single-delete/data.csv", + # "test-data/delete-single-arm/data.csv", package = "REDCapR" ) diff --git a/inst/test-data/delete-single-arm/data.csv b/inst/test-data/projects/arm-single-delete/data-old.csv similarity index 82% rename from inst/test-data/delete-single-arm/data.csv rename to inst/test-data/projects/arm-single-delete/data-old.csv index d43ed7fc..23dae98b 100644 --- a/inst/test-data/delete-single-arm/data.csv +++ b/inst/test-data/projects/arm-single-delete/data-old.csv @@ -1,9 +1,6 @@ record_id,birth_date,position,demographics_complete 101,2020-05-01,pg,2 -102,2020-06-01,sg,2 -103,2020-07-01,sf,2 104,2020-08-01,pf,2 -105,2020-09-01,c,2 106,2020-10-01,pg,2 107,2020-11-01,sg,2 108,2020-12-01,sf,2 @@ -18,4 +15,3 @@ record_id,birth_date,position,demographics_complete 117,2021-09-01,sg,2 118,2021-10-01,sf,2 119,2021-11-01,pf,2 -120,2021-12-01,c,2 diff --git a/inst/test-data/projects/arm-single-delete/data.csv b/inst/test-data/projects/arm-single-delete/data.csv index 23dae98b..d43ed7fc 100644 --- a/inst/test-data/projects/arm-single-delete/data.csv +++ b/inst/test-data/projects/arm-single-delete/data.csv @@ -1,6 +1,9 @@ record_id,birth_date,position,demographics_complete 101,2020-05-01,pg,2 +102,2020-06-01,sg,2 +103,2020-07-01,sf,2 104,2020-08-01,pf,2 +105,2020-09-01,c,2 106,2020-10-01,pg,2 107,2020-11-01,sg,2 108,2020-12-01,sf,2 @@ -15,3 +18,4 @@ record_id,birth_date,position,demographics_complete 117,2021-09-01,sg,2 118,2021-10-01,sf,2 119,2021-11-01,pf,2 +120,2021-12-01,c,2 From 49450daf786a1305cda51d703c4f6902f4b8452e Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Wed, 16 Oct 2024 21:00:20 -0500 Subject: [PATCH 06/21] consolidate data files ref #542 --- R/project-delete-multiple-arm.R | 3 +- .../arm-multiple-delete/data-old.csv} | 72 +++++++++---------- .../projects/arm-multiple-delete/data.csv | 72 ++++++++++--------- 3 files changed, 74 insertions(+), 73 deletions(-) rename inst/test-data/{delete-multiple-arm/data.csv => projects/arm-multiple-delete/data-old.csv} (93%) diff --git a/R/project-delete-multiple-arm.R b/R/project-delete-multiple-arm.R index d2bf46b1..24e55927 100644 --- a/R/project-delete-multiple-arm.R +++ b/R/project-delete-multiple-arm.R @@ -17,7 +17,8 @@ populate_project_delete_multiple_arm <- function(verbose = FALSE) { token = credential$token ) path_in <- system.file( - "test-data/delete-multiple-arm/data.csv", + "test-data/projects/arm-multiple-delete/data.csv", + # "test-data/delete-multiple-arm/data.csv", package = "REDCapR" ) diff --git a/inst/test-data/delete-multiple-arm/data.csv b/inst/test-data/projects/arm-multiple-delete/data-old.csv similarity index 93% rename from inst/test-data/delete-multiple-arm/data.csv rename to inst/test-data/projects/arm-multiple-delete/data-old.csv index e2aa42eb..a75b1b6f 100644 --- a/inst/test-data/delete-multiple-arm/data.csv +++ b/inst/test-data/projects/arm-multiple-delete/data-old.csv @@ -1,61 +1,57 @@ record_id,redcap_event_name,birth_date,position,demographics_complete 101,event_1_arm_1,2020-05-01,pg,2 -102,event_1_arm_1,2020-06-01,sg,2 -103,event_1_arm_1,2020-07-01,sf,2 -104,event_1_arm_1,2020-08-01,pf,2 -105,event_1_arm_1,2020-09-01,c,2 -106,event_1_arm_1,2020-10-01,pg,2 -107,event_1_arm_1,2020-11-01,sg,2 -108,event_1_arm_1,2020-12-01,sf,2 -109,event_1_arm_1,2021-01-01,pf,2 -110,event_1_arm_1,2021-02-01,c,2 -111,event_1_arm_1,2021-03-01,pg,2 -112,event_1_arm_1,2021-04-01,sg,2 -113,event_1_arm_1,2021-05-01,sf,2 -114,event_1_arm_1,2021-06-01,pf,2 -115,event_1_arm_1,2021-07-01,c,2 -116,event_1_arm_1,2021-08-01,pg,2 -117,event_1_arm_1,2021-09-01,sg,2 -118,event_1_arm_1,2021-10-01,sf,2 -119,event_1_arm_1,2021-11-01,pf,2 -120,event_1_arm_1,2021-12-01,c,2 101,event_1_arm_2,2020-05-01,pg,2 -102,event_1_arm_2,2020-06-01,sg,2 -103,event_1_arm_2,2020-07-01,sf,2 -104,event_1_arm_2,2020-08-01,pf,2 -105,event_1_arm_2,2020-09-01,c,2 -106,event_1_arm_2,2020-10-01,pg,2 -107,event_1_arm_2,2020-11-01,sg,2 -108,event_1_arm_2,2020-12-01,sf,2 -109,event_1_arm_2,2021-01-01,pf,2 -110,event_1_arm_2,2021-02-01,c,2 -111,event_1_arm_2,2021-03-01,pg,2 -112,event_1_arm_2,2021-04-01,sg,2 -113,event_1_arm_2,2021-05-01,sf,2 -114,event_1_arm_2,2021-06-01,pf,2 -115,event_1_arm_2,2021-07-01,c,2 -116,event_1_arm_2,2021-08-01,pg,2 -117,event_1_arm_2,2021-09-01,sg,2 -118,event_1_arm_2,2021-10-01,sf,2 -119,event_1_arm_2,2021-11-01,pf,2 -120,event_1_arm_2,2021-12-01,c,2 101,event_1_arm_3,2020-05-01,pg,2 +102,event_1_arm_1,2020-06-01,sg,2 102,event_1_arm_3,2020-06-01,sg,2 +103,event_1_arm_1,2020-07-01,sf,2 103,event_1_arm_3,2020-07-01,sf,2 +104,event_1_arm_1,2020-08-01,pf,2 +104,event_1_arm_2,2020-08-01,pf,2 104,event_1_arm_3,2020-08-01,pf,2 +105,event_1_arm_1,2020-09-01,c,2 105,event_1_arm_3,2020-09-01,c,2 +106,event_1_arm_1,2020-10-01,pg,2 +106,event_1_arm_2,2020-10-01,pg,2 106,event_1_arm_3,2020-10-01,pg,2 +107,event_1_arm_1,2020-11-01,sg,2 +107,event_1_arm_2,2020-11-01,sg,2 107,event_1_arm_3,2020-11-01,sg,2 +108,event_1_arm_1,2020-12-01,sf,2 +108,event_1_arm_2,2020-12-01,sf,2 108,event_1_arm_3,2020-12-01,sf,2 +109,event_1_arm_1,2021-01-01,pf,2 +109,event_1_arm_2,2021-01-01,pf,2 109,event_1_arm_3,2021-01-01,pf,2 +110,event_1_arm_1,2021-02-01,c,2 +110,event_1_arm_2,2021-02-01,c,2 110,event_1_arm_3,2021-02-01,c,2 +111,event_1_arm_1,2021-03-01,pg,2 +111,event_1_arm_2,2021-03-01,pg,2 111,event_1_arm_3,2021-03-01,pg,2 +112,event_1_arm_1,2021-04-01,sg,2 +112,event_1_arm_2,2021-04-01,sg,2 112,event_1_arm_3,2021-04-01,sg,2 +113,event_1_arm_1,2021-05-01,sf,2 +113,event_1_arm_2,2021-05-01,sf,2 113,event_1_arm_3,2021-05-01,sf,2 +114,event_1_arm_1,2021-06-01,pf,2 +114,event_1_arm_2,2021-06-01,pf,2 114,event_1_arm_3,2021-06-01,pf,2 +115,event_1_arm_1,2021-07-01,c,2 +115,event_1_arm_2,2021-07-01,c,2 115,event_1_arm_3,2021-07-01,c,2 +116,event_1_arm_1,2021-08-01,pg,2 +116,event_1_arm_2,2021-08-01,pg,2 116,event_1_arm_3,2021-08-01,pg,2 +117,event_1_arm_1,2021-09-01,sg,2 +117,event_1_arm_2,2021-09-01,sg,2 117,event_1_arm_3,2021-09-01,sg,2 +118,event_1_arm_1,2021-10-01,sf,2 +118,event_1_arm_2,2021-10-01,sf,2 118,event_1_arm_3,2021-10-01,sf,2 +119,event_1_arm_1,2021-11-01,pf,2 +119,event_1_arm_2,2021-11-01,pf,2 119,event_1_arm_3,2021-11-01,pf,2 +120,event_1_arm_1,2021-12-01,c,2 120,event_1_arm_3,2021-12-01,c,2 diff --git a/inst/test-data/projects/arm-multiple-delete/data.csv b/inst/test-data/projects/arm-multiple-delete/data.csv index a75b1b6f..e2aa42eb 100644 --- a/inst/test-data/projects/arm-multiple-delete/data.csv +++ b/inst/test-data/projects/arm-multiple-delete/data.csv @@ -1,57 +1,61 @@ record_id,redcap_event_name,birth_date,position,demographics_complete 101,event_1_arm_1,2020-05-01,pg,2 -101,event_1_arm_2,2020-05-01,pg,2 -101,event_1_arm_3,2020-05-01,pg,2 102,event_1_arm_1,2020-06-01,sg,2 -102,event_1_arm_3,2020-06-01,sg,2 103,event_1_arm_1,2020-07-01,sf,2 -103,event_1_arm_3,2020-07-01,sf,2 104,event_1_arm_1,2020-08-01,pf,2 -104,event_1_arm_2,2020-08-01,pf,2 -104,event_1_arm_3,2020-08-01,pf,2 105,event_1_arm_1,2020-09-01,c,2 -105,event_1_arm_3,2020-09-01,c,2 106,event_1_arm_1,2020-10-01,pg,2 -106,event_1_arm_2,2020-10-01,pg,2 -106,event_1_arm_3,2020-10-01,pg,2 107,event_1_arm_1,2020-11-01,sg,2 -107,event_1_arm_2,2020-11-01,sg,2 -107,event_1_arm_3,2020-11-01,sg,2 108,event_1_arm_1,2020-12-01,sf,2 -108,event_1_arm_2,2020-12-01,sf,2 -108,event_1_arm_3,2020-12-01,sf,2 109,event_1_arm_1,2021-01-01,pf,2 -109,event_1_arm_2,2021-01-01,pf,2 -109,event_1_arm_3,2021-01-01,pf,2 110,event_1_arm_1,2021-02-01,c,2 -110,event_1_arm_2,2021-02-01,c,2 -110,event_1_arm_3,2021-02-01,c,2 111,event_1_arm_1,2021-03-01,pg,2 -111,event_1_arm_2,2021-03-01,pg,2 -111,event_1_arm_3,2021-03-01,pg,2 112,event_1_arm_1,2021-04-01,sg,2 -112,event_1_arm_2,2021-04-01,sg,2 -112,event_1_arm_3,2021-04-01,sg,2 113,event_1_arm_1,2021-05-01,sf,2 -113,event_1_arm_2,2021-05-01,sf,2 -113,event_1_arm_3,2021-05-01,sf,2 114,event_1_arm_1,2021-06-01,pf,2 -114,event_1_arm_2,2021-06-01,pf,2 -114,event_1_arm_3,2021-06-01,pf,2 115,event_1_arm_1,2021-07-01,c,2 -115,event_1_arm_2,2021-07-01,c,2 -115,event_1_arm_3,2021-07-01,c,2 116,event_1_arm_1,2021-08-01,pg,2 -116,event_1_arm_2,2021-08-01,pg,2 -116,event_1_arm_3,2021-08-01,pg,2 117,event_1_arm_1,2021-09-01,sg,2 -117,event_1_arm_2,2021-09-01,sg,2 -117,event_1_arm_3,2021-09-01,sg,2 118,event_1_arm_1,2021-10-01,sf,2 -118,event_1_arm_2,2021-10-01,sf,2 -118,event_1_arm_3,2021-10-01,sf,2 119,event_1_arm_1,2021-11-01,pf,2 +120,event_1_arm_1,2021-12-01,c,2 +101,event_1_arm_2,2020-05-01,pg,2 +102,event_1_arm_2,2020-06-01,sg,2 +103,event_1_arm_2,2020-07-01,sf,2 +104,event_1_arm_2,2020-08-01,pf,2 +105,event_1_arm_2,2020-09-01,c,2 +106,event_1_arm_2,2020-10-01,pg,2 +107,event_1_arm_2,2020-11-01,sg,2 +108,event_1_arm_2,2020-12-01,sf,2 +109,event_1_arm_2,2021-01-01,pf,2 +110,event_1_arm_2,2021-02-01,c,2 +111,event_1_arm_2,2021-03-01,pg,2 +112,event_1_arm_2,2021-04-01,sg,2 +113,event_1_arm_2,2021-05-01,sf,2 +114,event_1_arm_2,2021-06-01,pf,2 +115,event_1_arm_2,2021-07-01,c,2 +116,event_1_arm_2,2021-08-01,pg,2 +117,event_1_arm_2,2021-09-01,sg,2 +118,event_1_arm_2,2021-10-01,sf,2 119,event_1_arm_2,2021-11-01,pf,2 +120,event_1_arm_2,2021-12-01,c,2 +101,event_1_arm_3,2020-05-01,pg,2 +102,event_1_arm_3,2020-06-01,sg,2 +103,event_1_arm_3,2020-07-01,sf,2 +104,event_1_arm_3,2020-08-01,pf,2 +105,event_1_arm_3,2020-09-01,c,2 +106,event_1_arm_3,2020-10-01,pg,2 +107,event_1_arm_3,2020-11-01,sg,2 +108,event_1_arm_3,2020-12-01,sf,2 +109,event_1_arm_3,2021-01-01,pf,2 +110,event_1_arm_3,2021-02-01,c,2 +111,event_1_arm_3,2021-03-01,pg,2 +112,event_1_arm_3,2021-04-01,sg,2 +113,event_1_arm_3,2021-05-01,sf,2 +114,event_1_arm_3,2021-06-01,pf,2 +115,event_1_arm_3,2021-07-01,c,2 +116,event_1_arm_3,2021-08-01,pg,2 +117,event_1_arm_3,2021-09-01,sg,2 +118,event_1_arm_3,2021-10-01,sf,2 119,event_1_arm_3,2021-11-01,pf,2 -120,event_1_arm_1,2021-12-01,c,2 120,event_1_arm_3,2021-12-01,c,2 From 4e01ff50d0d3c393696bf9d7ad672ff8db142454 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Wed, 16 Oct 2024 21:15:02 -0500 Subject: [PATCH 07/21] provide redirection for plug urls ref #542 --- R/helpers-testing.R | 36 +++++++++++++++++++++++++++++++- R/project-dag-write.R | 5 +++-- R/project-delete-multiple-arm.R | 4 ++-- R/project-delete-single-arm.R | 4 ++-- R/project-simple.R | 4 ++-- inst/misc/plugin-redirection.yml | 15 +++++++++++++ tests/test-all.R | 4 ++++ 7 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 inst/misc/plugin-redirection.yml diff --git a/R/helpers-testing.R b/R/helpers-testing.R index 60500745..5eafc1f1 100644 --- a/R/helpers-testing.R +++ b/R/helpers-testing.R @@ -49,7 +49,42 @@ retrieve_credential_testing <- function(project_tag = "simple", server_instance username = username ) } +retrieve_plugins <- function(plugin_name, server_instance = "dev-2") { + checkmate::assert_character(plugin_name , any.missing = FALSE, min.chars = 2, max.chars = 50) + checkmate::assert_character(server_instance , any.missing = FALSE, min.chars = 2, max.chars = 50) + + # This line avoids a warning from the package check. + plugins <- instance <- tag <- project_tag <- NULL + + if (!requireNamespace("yaml", quietly = TRUE)) { + stop( + "Package `yaml` must be installed to use this function.", + call. = FALSE + ) + } + d_map <- + system.file("misc/plugin-redirection.yml", package = "REDCapR") |> + yaml::yaml.load_file( + handlers = list(map = \(x) tibble::as_tibble(x)) + ) |> + dplyr::bind_rows() |> + tidyr::unnest(plugins) |> + tidyr::pivot_longer( + cols = -c("instance"), + names_to = "tag", + values_to = "url" + ) |> + tidyr::drop_na(url) |> + dplyr::filter(instance == server_instance) |> + dplyr::filter(tag == plugin_name) + + if (nrow(d_map) == 0L) { + stop("A plugin mapping entry does not exist for the desired arguments.") + } + d_map |> + dplyr::pull(url) +} # This function isn't used during testing itself. Just to create the expected file. save_expected <- function(o, path) { # nocov start @@ -60,7 +95,6 @@ save_expected <- function(o, path) { dput(o, path) # nocov end } - retrieve_expected <- function(path) { full_path <- system.file(path, package = "REDCapR") if (!file.exists(full_path)) diff --git a/R/project-dag-write.R b/R/project-dag-write.R index 0bb46177..7cb8a7a5 100644 --- a/R/project-dag-write.R +++ b/R/project-dag-write.R @@ -94,8 +94,9 @@ clear_project_dag_write <- function(verbose = FALSE) { ) # nocov end } - path_delete_test_record <- - "https://redcap-dev-2.ouhsc.edu/redcap/plugins/redcapr/delete_redcapr_dag_write.php" + + path_delete_test_record <- retrieve_plugins("delete_dag") + # "https://redcap-dev-2.ouhsc.edu/redcap/plugins/redcapr/delete_redcapr_dag_write.php" # Returns a boolean value if successful was_successful <- !httr::http_error(path_delete_test_record) diff --git a/R/project-delete-multiple-arm.R b/R/project-delete-multiple-arm.R index 24e55927..9ae31587 100644 --- a/R/project-delete-multiple-arm.R +++ b/R/project-delete-multiple-arm.R @@ -64,8 +64,8 @@ clear_project_delete_multiple_arm <- function(verbose = TRUE) { ) # nocov end } - path_delete_test_record <- - "https://redcap-dev-2.ouhsc.edu/redcap/plugins/redcapr/delete_redcapr_delete_multiple_arm.php" + path_delete_test_record <- retrieve_plugins("delete_arm_multiple") + # "https://redcap-dev-2.ouhsc.edu/redcap/plugins/redcapr/delete_redcapr_delete_multiple_arm.php" # Returns a boolean value if successful was_successful <- !httr::http_error(path_delete_test_record) diff --git a/R/project-delete-single-arm.R b/R/project-delete-single-arm.R index 59ba691a..0efa2685 100644 --- a/R/project-delete-single-arm.R +++ b/R/project-delete-single-arm.R @@ -64,8 +64,8 @@ clear_project_delete_single_arm <- function(verbose = FALSE) { ) # nocov end } - path_delete_test_record <- - "https://redcap-dev-2.ouhsc.edu/redcap/plugins/redcapr/delete_redcapr_delete_single_arm.php" + path_delete_test_record <- retrieve_plugins("delete_arm_single") + # "https://redcap-dev-2.ouhsc.edu/redcap/plugins/redcapr/delete_redcapr_delete_single_arm.php" # Returns a boolean value if successful was_successful <- !httr::http_error(path_delete_test_record) diff --git a/R/project-simple.R b/R/project-simple.R index f055869c..ca56c9da 100644 --- a/R/project-simple.R +++ b/R/project-simple.R @@ -89,8 +89,8 @@ clear_project_simple <- function(verbose = TRUE) { ) # nocov end } - path_delete_test_record <- - "https://redcap-dev-2.ouhsc.edu/redcap/plugins/redcapr/delete_redcapr_simple.php" + path_delete_test_record <- retrieve_plugins("delete_simple") + # "https://redcap-dev-2.ouhsc.edu/redcap/plugins/redcapr/delete_redcapr_simple.php" # Returns a boolean value if successful was_successful <- !httr::http_error(path_delete_test_record) diff --git a/inst/misc/plugin-redirection.yml b/inst/misc/plugin-redirection.yml new file mode 100644 index 00000000..0aeb5d5a --- /dev/null +++ b/inst/misc/plugin-redirection.yml @@ -0,0 +1,15 @@ +- + instance: bbmc + plugins: + - delete_simple : "https://bbmc.ouhsc.edu/redcap/plugins/redcapr/delete_redcapr_simple.php" + - delete_arm_single : "https://bbmc.ouhsc.edu/redcap/plugins/redcapr/delete_redcapr_delete_single_arm.php" + - delete_arm_multiple : "https://bbmc.ouhsc.edu/redcap/plugins/redcapr/delete_redcapr_delete_multiple_arm.php" + - delete_dag : "https://bbmc.ouhsc.edu/redcap/plugins/redcapr/delete_redcapr_dag_write.php" + +- + instance: dev-2 + plugins: + - delete_simple : "https://redcap-dev-2.ouhsc.edu/redcap/plugins/redcapr/delete_redcapr_simple.php" + - delete_arm_single : "https://redcap-dev-2.ouhsc.edu/redcap/plugins/redcapr/delete_redcapr_delete_single_arm.php" + - delete_arm_multiple : "https://redcap-dev-2.ouhsc.edu/redcap/plugins/redcapr/delete_redcapr_delete_multiple_arm.php" + - delete_dag : "https://redcap-dev-2.ouhsc.edu/redcap/plugins/redcapr/delete_redcapr_dag_write.php" diff --git a/tests/test-all.R b/tests/test-all.R index 0e17353a..6cff8edb 100644 --- a/tests/test-all.R +++ b/tests/test-all.R @@ -2,5 +2,9 @@ library(testthat) library(REDCapR) +Sys.setenv("redcapr_test_server" = "dev-2") + +message("Using test server '", Sys.getenv("redcapr_test_server"), "'.") + # source("R/helpers-testing.R") testthat::test_check("REDCapR") From fb20d11a222401504c4d943f180e4a4b5dbe63e8 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 17 Oct 2024 12:29:21 -0500 Subject: [PATCH 08/21] starting to make server a variable ref #544 --- R/helpers-testing.R | 23 ++++++++++++++++--- tests/test-all.R | 3 ++- .../testthat/test-retrieve-credential-local.R | 10 ++++---- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/R/helpers-testing.R b/R/helpers-testing.R index 5eafc1f1..39d4c5b3 100644 --- a/R/helpers-testing.R +++ b/R/helpers-testing.R @@ -1,8 +1,18 @@ -retrieve_credential_testing <- function(project_tag = "simple", server_instance = "dev-2", username = NA_character_) { +retrieve_credential_testing <- function( + project_tag = "simple", + username = NA_character_ + ) { checkmate::assert_character(project_tag , any.missing = FALSE, min.chars = 2, max.chars = 50) - checkmate::assert_character(server_instance , any.missing = FALSE, min.chars = 2, max.chars = 50) checkmate::assert_character(username , any.missing = TRUE , min.chars = 2, max.chars = 50) + server_instance <- + # if(Sys.getenv("redcapr_test_server") != "") { + Sys.getenv("redcapr_test_server") + # } else { + # "dev-2" + # } + checkmate::assert_character(server_instance , any.missing = FALSE, min.chars = 2, max.chars = 50) + # This line avoids a warning from the package check. projects <- project_id <- instance <- tag <- NULL @@ -49,8 +59,15 @@ retrieve_credential_testing <- function(project_tag = "simple", server_instance username = username ) } -retrieve_plugins <- function(plugin_name, server_instance = "dev-2") { +retrieve_plugins <- function(plugin_name) { checkmate::assert_character(plugin_name , any.missing = FALSE, min.chars = 2, max.chars = 50) + + server_instance <- + # if(Sys.getenv("redcapr_test_server") != "") { + Sys.getenv("redcapr_test_server") + # } else { + # "dev-2" + # } checkmate::assert_character(server_instance , any.missing = FALSE, min.chars = 2, max.chars = 50) # This line avoids a warning from the package check. diff --git a/tests/test-all.R b/tests/test-all.R index 6cff8edb..0b1d105d 100644 --- a/tests/test-all.R +++ b/tests/test-all.R @@ -2,7 +2,8 @@ library(testthat) library(REDCapR) -Sys.setenv("redcapr_test_server" = "dev-2") +# Sys.setenv("redcapr_test_server" = "dev-2") +Sys.setenv("redcapr_test_server" = "bbmc") message("Using test server '", Sys.getenv("redcapr_test_server"), "'.") diff --git a/tests/testthat/test-retrieve-credential-local.R b/tests/testthat/test-retrieve-credential-local.R index ed369808..27d508f2 100644 --- a/tests/testthat/test-retrieve-credential-local.R +++ b/tests/testthat/test-retrieve-credential-local.R @@ -25,9 +25,9 @@ test_that("Good Credentials", { expected_write_token <- "F9CBFFF78C3D78F641BAE9623F6B7E6A" expected_write_comment <- "simple-write" - credential_read <- retrieve_credential_testing(server_instance = "dev-2") # This project is for testing only reading from the server. - credential_longitudinal <- retrieve_credential_testing(server_instance = "dev-2","longitudinal") # This project is for testing reading longitudinal projects. - credential_write <- retrieve_credential_testing(server_instance = "dev-2","simple-write") # This project is for testing reading & writing. + credential_read <- retrieve_credential_testing() # This project is for testing only reading from the server. + credential_longitudinal <- retrieve_credential_testing("longitudinal") # This project is for testing reading longitudinal projects. + credential_write <- retrieve_credential_testing("simple-write") # This project is for testing reading & writing. expect_equal(credential_read$redcap_uri , expected_read_redcap_uri) expect_equal(credential_read$username , expected_read_username) @@ -60,8 +60,8 @@ test_that("Multiple users", { expected_user_token <- "8092B2302CAA359C4F5641AEC1CE72ED" expected_user_comment <- "dag-write --group A" - credential_admin <- retrieve_credential_testing(server_instance = "dev-2", username = expected_admin_username) - credential_user <- retrieve_credential_testing(server_instance = "dev-2", username = expected_user_username) + credential_admin <- retrieve_credential_testing(username = expected_admin_username) + credential_user <- retrieve_credential_testing(username = expected_user_username) expect_equal(credential_admin$redcap_uri , expected_admin_redcap_uri) expect_equal(credential_admin$username , expected_admin_username) From de616f615f8ab2dadf8cd38564f674587fdf272f Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 17 Oct 2024 12:29:40 -0500 Subject: [PATCH 09/21] portable DAG ID checks ref #544 --- .../users-export/with-dags--user.R | 11 +++++------ tests/testthat/test-users-export.R | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/inst/test-data/specific-redcapr/users-export/with-dags--user.R b/inst/test-data/specific-redcapr/users-export/with-dags--user.R index 8c617909..b4bf2d78 100644 --- a/inst/test-data/specific-redcapr/users-export/with-dags--user.R +++ b/inst/test-data/specific-redcapr/users-export/with-dags--user.R @@ -1,11 +1,10 @@ structure(list(username = "unittestphifree", firstname = "Unit Test", lastname = "Phi Free", expiration = structure(NA_real_, class = "Date"), - data_access_group = "daga", data_access_group_id = "20", - design = FALSE, alerts = 0, user_rights = 2L, data_access_groups = FALSE, - reports = FALSE, stats_and_charts = FALSE, manage_survey_participants = TRUE, - calendar = FALSE, data_import_tool = FALSE, data_comparison_tool = FALSE, - logging = FALSE, email_logging = FALSE, file_repository = FALSE, - data_quality_create = FALSE, data_quality_execute = FALSE, + data_access_group = "daga", design = FALSE, alerts = 0, user_rights = 2L, + data_access_groups = FALSE, reports = FALSE, stats_and_charts = FALSE, + manage_survey_participants = TRUE, calendar = FALSE, data_import_tool = FALSE, + data_comparison_tool = FALSE, logging = FALSE, email_logging = FALSE, + file_repository = FALSE, data_quality_create = FALSE, data_quality_execute = FALSE, api_export = TRUE, api_import = FALSE, api_modules = FALSE, mobile_app = FALSE, mobile_app_download_data = FALSE, record_create = FALSE, record_rename = FALSE, record_delete = FALSE, lock_records_all_forms = FALSE, diff --git a/tests/testthat/test-users-export.R b/tests/testthat/test-users-export.R index 28b32cb0..66630488 100644 --- a/tests/testthat/test-users-export.R +++ b/tests/testthat/test-users-export.R @@ -43,6 +43,23 @@ test_that("with-dags", { -email ) + # Check the group id exists + expect_true(!is.na(d_user$data_access_group_id)) + + # For these two specific servers, check the exact value of the id + if (credential_1$redcap_uri == "https://redcap-dev-2.ouhsc.edu/redcap/api/") { + expect_equal(d_user$data_access_group_id, "20") + } else if (credential_1$redcap_uri == "https://bbmc.ouhsc.edu/redcap/api/") { + expect_equal(d_user$data_access_group_id, "331") + } + + # Drop the ID because it won't match other servers + d_user <- + d_user |> + dplyr::select( + -data_access_group_id + ) + d_user_form <- returned_object$data_user_form |> dplyr::filter(username == "unittestphifree") From 08b99a98f707ce0e32905620822fa44f868c3c82 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 17 Oct 2024 12:31:35 -0500 Subject: [PATCH 10/21] null values for untouched checkboxes ref #544 --- .../specific-redcapr/read-oneshot/blank-for-gray-true.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inst/test-data/specific-redcapr/read-oneshot/blank-for-gray-true.R b/inst/test-data/specific-redcapr/read-oneshot/blank-for-gray-true.R index 07b062c9..2ae2f087 100644 --- a/inst/test-data/specific-redcapr/read-oneshot/blank-for-gray-true.R +++ b/inst/test-data/specific-redcapr/read-oneshot/blank-for-gray-true.R @@ -17,12 +17,12 @@ NA), dob = structure(c(12294, 12121, -13051, -6269, -5375, NA "Had a hand for trouble and a eye for cash\n\nHe had a gold watch chain and a black mustache", NA), mugshot = c("mugshot-1.jpg", "mugshot-2.jpg", "mugshot-3.jpg", "mugshot-4.jpg", "mugshot-5.jpg", NA), health_complete = c(1, - 0, 2, 2, 0, 0), race___1 = c(0, 0, 0, 0, 1, 0), race___2 = c(0, + 0, 2, 2, 0, NA), race___1 = c(0, 0, 0, 0, 1, 0), race___2 = c(0, 0, 0, 1, 0, 0), race___3 = c(0, 1, 0, 0, 0, 0), race___4 = c(0, 0, 1, 0, 0, 0), race___5 = c(1, 1, 1, 1, 0, 0), race___6 = c(0, 0, 0, 0, 1, 0), ethnicity = c(1, 1, 0, 1, 2, NA), interpreter_needed = c(0, 0, 1, NA, 0, NA), race_and_ethnicity_complete = c(2, 0, 2, - 2, 2, 0)), row.names = c(NA, -6L), spec = structure(list( + 2, 2, NA)), row.names = c(NA, -6L), spec = structure(list( cols = list(record_id = structure(list(), class = c("collector_double", "collector")), name_first = structure(list(), class = c("collector_character", "collector")), name_last = structure(list(), class = c("collector_character", From b64a7b70cb92ca0298321bfb885a7182e7fcd2cc Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 17 Oct 2024 12:41:12 -0500 Subject: [PATCH 11/21] portable local credential tests ref #544 --- inst/test-data/projects/README.md | 8 +++-- .../testthat/test-retrieve-credential-local.R | 31 +++++++++---------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/inst/test-data/projects/README.md b/inst/test-data/projects/README.md index a9ea7d66..a139872f 100644 --- a/inst/test-data/projects/README.md +++ b/inst/test-data/projects/README.md @@ -3,6 +3,8 @@ Test Projects Steps to recreate on a fresh server -1. Create two accounts for testing. - The names shouldn't matter, but we named them 'unittestphifree' and 'unittestphifree-dag1'. - Table-based accounts are probably easiest. \ No newline at end of file +1. Create two accounts for testing: + Table-based accounts are probably easiest. + Tests are case-sensitive. + 1. 'unittestphifree': First name = "Unit Test"; Last name "Phi Free". + 1. 'unittestphifree-dag1': First name = "Unit Test"; Last name "PHI Free DAG1" diff --git a/tests/testthat/test-retrieve-credential-local.R b/tests/testthat/test-retrieve-credential-local.R index 27d508f2..e9d99248 100644 --- a/tests/testthat/test-retrieve-credential-local.R +++ b/tests/testthat/test-retrieve-credential-local.R @@ -3,73 +3,70 @@ library(testthat) path <- system.file("misc/dev-2.credentials", package="REDCapR") pid_read <- 33L # This project is for testing only reading from the server. pid_longitudinal <- 34L # This project is for testing reading longitudinal projects. -# pid_write <- 35L # This project is for testing reading & writing. -# pid_dag <- 49L #This project is for testing DAGs. +pid_write <- 36L # This project is for testing reading & writing. +pid_dag_write <- 49L #This project is for testing DAGs. test_that("Good Credentials", { - expected_read_redcap_uri <- "https://redcap-dev-2.ouhsc.edu/redcap/api/" + expected_redcap_uri <- "https://redcap-dev-2.ouhsc.edu/redcap/api/" expected_read_username <- "myusername" # expected_read_project_id <- pid_read expected_read_token <- "9A068C425B1341D69E83064A2D273A70" expected_read_comment <- "simple" - expected_longitudinal_redcap_uri <- "https://redcap-dev-2.ouhsc.edu/redcap/api/" expected_longitudinal_username <- "myusername" # expected_longitudinal_project_id <- pid_longitudinal expected_longitudinal_token <- "DA6F2BB23146BD5A7EA3408C1A44A556" expected_longitudinal_comment <- "longitudinal" - expected_write_redcap_uri <- "https://redcap-dev-2.ouhsc.edu/redcap/api/" expected_write_username <- "myusername" # expected_write_project_id <- pid_write expected_write_token <- "F9CBFFF78C3D78F641BAE9623F6B7E6A" expected_write_comment <- "simple-write" - credential_read <- retrieve_credential_testing() # This project is for testing only reading from the server. - credential_longitudinal <- retrieve_credential_testing("longitudinal") # This project is for testing reading longitudinal projects. - credential_write <- retrieve_credential_testing("simple-write") # This project is for testing reading & writing. + credential_read <- retrieve_credential_local(path_credential = path, project_id = pid_read) # This project is for testing only reading from the server. + credential_longitudinal <- retrieve_credential_local(path_credential = path, project_id = pid_longitudinal) # This project is for testing reading longitudinal projects. + credential_write <- retrieve_credential_local(path_credential = path, project_id = pid_write) # This project is for testing reading & writing. - expect_equal(credential_read$redcap_uri , expected_read_redcap_uri) + expect_equal(credential_read$redcap_uri , expected_redcap_uri) expect_equal(credential_read$username , expected_read_username) # expect_equal(credential_read$project_id , expected_read_project_id) expect_equal(credential_read$token , expected_read_token) expect_equal(credential_read$comment , expected_read_comment) - expect_equal(credential_longitudinal$redcap_uri , expected_longitudinal_redcap_uri) + expect_equal(credential_longitudinal$redcap_uri , expected_redcap_uri) expect_equal(credential_longitudinal$username , expected_longitudinal_username) # expect_equal(credential_longitudinal$project_id , expected_longitudinal_project_id) expect_equal(credential_longitudinal$token , expected_longitudinal_token) expect_equal(credential_longitudinal$comment , expected_longitudinal_comment) - expect_equal(credential_write$redcap_uri , expected_write_redcap_uri) + expect_equal(credential_write$redcap_uri , expected_redcap_uri) expect_equal(credential_write$username , expected_write_username) # expect_equal(credential_write$project_id , expected_write_project_id) expect_equal(credential_write$token , expected_write_token) expect_equal(credential_write$comment , expected_write_comment) }) test_that("Multiple users", { - expected_admin_redcap_uri <- "https://redcap-dev-2.ouhsc.edu/redcap/api/" + expected_redcap_uri <- "https://redcap-dev-2.ouhsc.edu/redcap/api/" expected_admin_username <- "admin" # expected_admin_project_id <- pid_dag expected_admin_token <- "F6F871FE0322EEE8D23F56DBBE23B756" expected_admin_comment <- "dag-write --admin" - expected_user_redcap_uri <- "https://redcap-dev-2.ouhsc.edu/redcap/api/" expected_user_username <- "user-dag1" # expected_user_project_id <- pid_dag expected_user_token <- "8092B2302CAA359C4F5641AEC1CE72ED" expected_user_comment <- "dag-write --group A" - credential_admin <- retrieve_credential_testing(username = expected_admin_username) - credential_user <- retrieve_credential_testing(username = expected_user_username) + credential_admin <- retrieve_credential_local(path_credential = path, project_id = pid_dag_write, username = expected_admin_username) # This project is for testing only reading from the server. + credential_user <- retrieve_credential_local(path_credential = path, project_id = pid_dag_write, username = expected_user_username) # This project is for testing reading longitudinal projects. - expect_equal(credential_admin$redcap_uri , expected_admin_redcap_uri) + expect_equal(credential_admin$redcap_uri , expected_redcap_uri) expect_equal(credential_admin$username , expected_admin_username) # expect_equal(credential_admin$project_id , expected_admin_project_id) expect_equal(credential_admin$token , expected_admin_token) expect_equal(credential_admin$comment , expected_admin_comment) - expect_equal(credential_user$redcap_uri , expected_user_redcap_uri) + expect_equal(credential_user$redcap_uri , expected_redcap_uri) expect_equal(credential_user$username , expected_user_username) # expect_equal(credential_user$project_id , expected_user_project_id) expect_equal(credential_user$token , expected_user_token) From f50f05791b18295b9601f5abb3c7433ed37cfeae Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 17 Oct 2024 12:43:34 -0500 Subject: [PATCH 12/21] NA for incomplete checkboxes ref #542 --- .../specific-redcapr/read-oneshot-eav/blank-for-gray-true.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inst/test-data/specific-redcapr/read-oneshot-eav/blank-for-gray-true.R b/inst/test-data/specific-redcapr/read-oneshot-eav/blank-for-gray-true.R index bc4cccd6..cd7aa945 100644 --- a/inst/test-data/specific-redcapr/read-oneshot-eav/blank-for-gray-true.R +++ b/inst/test-data/specific-redcapr/read-oneshot-eav/blank-for-gray-true.R @@ -17,6 +17,6 @@ NA), dob = c("2003-08-30", "2003-03-10", "1934-04-09", "1952-11-02", NA), race___123456 = c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), ethnicity = c(1L, 1L, 0L, 1L, 2L, NA), interpreter_needed = c(0L, 0L, 1L, NA, 0L, NA), demographics_complete = c(2L, 2L, 2L, - 2L, 2L, 0L), health_complete = c(1L, 0L, 2L, 2L, 0L, 0L), - race_and_ethnicity_complete = c(2L, 0L, 2L, 2L, 2L, 0L)), row.names = c(NA, + 2L, 2L, 0L), health_complete = c(1L, 0L, 2L, 2L, 0L, NA), + race_and_ethnicity_complete = c(2L, 0L, 2L, 2L, 2L, NA)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame")) From 41904a39b50552ec82975cb750c3e27740b0a383 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 17 Oct 2024 12:44:17 -0500 Subject: [PATCH 13/21] NA for incomplete checkboxes ref #542 --- .../specific-redcapr/read-oneshot-eav/blank-for-gray-false.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inst/test-data/specific-redcapr/read-oneshot-eav/blank-for-gray-false.R b/inst/test-data/specific-redcapr/read-oneshot-eav/blank-for-gray-false.R index bc4cccd6..cd7aa945 100644 --- a/inst/test-data/specific-redcapr/read-oneshot-eav/blank-for-gray-false.R +++ b/inst/test-data/specific-redcapr/read-oneshot-eav/blank-for-gray-false.R @@ -17,6 +17,6 @@ NA), dob = c("2003-08-30", "2003-03-10", "1934-04-09", "1952-11-02", NA), race___123456 = c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), ethnicity = c(1L, 1L, 0L, 1L, 2L, NA), interpreter_needed = c(0L, 0L, 1L, NA, 0L, NA), demographics_complete = c(2L, 2L, 2L, - 2L, 2L, 0L), health_complete = c(1L, 0L, 2L, 2L, 0L, 0L), - race_and_ethnicity_complete = c(2L, 0L, 2L, 2L, 2L, 0L)), row.names = c(NA, + 2L, 2L, 0L), health_complete = c(1L, 0L, 2L, 2L, 0L, NA), + race_and_ethnicity_complete = c(2L, 0L, 2L, 2L, 2L, NA)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame")) From 0e113cc89ddd5d539f57d3f8a37636066b8db280 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 17 Oct 2024 14:47:16 -0500 Subject: [PATCH 14/21] skip eav test on non-dev server ref #544 --- tests/testthat/test-read-eav-oneshot.R | 4 ++++ tests/testthat/test-read-oneshot-eav.R | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/tests/testthat/test-read-eav-oneshot.R b/tests/testthat/test-read-eav-oneshot.R index a82a1b2f..b7235048 100644 --- a/tests/testthat/test-read-eav-oneshot.R +++ b/tests/testthat/test-read-eav-oneshot.R @@ -4,6 +4,10 @@ credential <- retrieve_credential_testing() update_expectation <- FALSE path_expected_default <- "test-data/specific-redcapr/read-eav-oneshot/default.R" +if (credential$redcap_uri != "https://redcap-dev-2.ouhsc.edu/redcap/api/") { + testthat::skip("Skipping EAV test on non-dev server") +} + test_that("smoke test", { testthat::skip_on_cran() expect_message({ diff --git a/tests/testthat/test-read-oneshot-eav.R b/tests/testthat/test-read-oneshot-eav.R index 244d9275..e3fdffb1 100644 --- a/tests/testthat/test-read-oneshot-eav.R +++ b/tests/testthat/test-read-oneshot-eav.R @@ -3,6 +3,10 @@ library(testthat) credential <- retrieve_credential_testing() update_expectation <- FALSE +if (credential$redcap_uri != "https://redcap-dev-2.ouhsc.edu/redcap/api/") { + testthat::skip("Skipping EAV test on non-dev server") +} + test_that("smoke test", { testthat::skip_on_cran() suppressMessages({ From 850ba001dc8499c5aab4f50f75fe227d2e590e70 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 17 Oct 2024 14:48:28 -0500 Subject: [PATCH 15/21] null values for untouched checkboxes ref #542 --- .../read-eav-oneshot/blank-for-gray-true.R | 61 ++++++++++--------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/inst/test-data/specific-redcapr/read-eav-oneshot/blank-for-gray-true.R b/inst/test-data/specific-redcapr/read-eav-oneshot/blank-for-gray-true.R index 9d89ea96..3786c7f3 100644 --- a/inst/test-data/specific-redcapr/read-eav-oneshot/blank-for-gray-true.R +++ b/inst/test-data/specific-redcapr/read-eav-oneshot/blank-for-gray-true.R @@ -6,41 +6,42 @@ structure(list(record = c("1", "1", "1", "1", "1", "1", "1", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", -"6", "6", "6", "6", "6", "6"), field_name = c("record_id", "name_first", +"6", "6", "6", "6"), field_name = c("record_id", "name_first", "name_last", "address", "telephone", "email", "dob", "age", "sex", -"demographics_complete", "height", "weight", "comments", "health_complete", +"demographics_complete", "height", "weight", "bmi", "comments", +"health_complete", "race", "ethnicity", "interpreter_needed", +"race_and_ethnicity_complete", "record_id", "name_first", "name_last", +"address", "telephone", "email", "dob", "age", "sex", "demographics_complete", +"height", "weight", "bmi", "comments", "health_complete", "race", "race", "ethnicity", "interpreter_needed", "race_and_ethnicity_complete", -"bmi", "record_id", "name_first", "name_last", "address", "telephone", +"record_id", "name_first", "name_last", "address", "telephone", "email", "dob", "age", "sex", "demographics_complete", "height", -"weight", "comments", "health_complete", "race", "race", "ethnicity", -"interpreter_needed", "race_and_ethnicity_complete", "bmi", "record_id", -"name_first", "name_last", "address", "telephone", "email", "dob", -"age", "sex", "demographics_complete", "height", "weight", "comments", -"health_complete", "race", "race", "ethnicity", "interpreter_needed", -"race_and_ethnicity_complete", "bmi", "record_id", "name_first", -"name_last", "address", "telephone", "email", "dob", "age", "sex", -"demographics_complete", "height", "weight", "comments", "health_complete", -"race", "race", "ethnicity", "race_and_ethnicity_complete", "bmi", +"weight", "bmi", "comments", "health_complete", "race", "race", +"ethnicity", "interpreter_needed", "race_and_ethnicity_complete", "record_id", "name_first", "name_last", "address", "telephone", "email", "dob", "age", "sex", "demographics_complete", "height", -"weight", "comments", "health_complete", "race", "race", "ethnicity", -"interpreter_needed", "race_and_ethnicity_complete", "bmi", "record_id", -"name_first", "name_last", "demographics_complete", "health_complete", -"race_and_ethnicity_complete"), value = c("1", "Nutmeg", "Nutmouse", +"weight", "bmi", "comments", "health_complete", "race", "race", +"ethnicity", "race_and_ethnicity_complete", "record_id", "name_first", +"name_last", "address", "telephone", "email", "dob", "age", "sex", +"demographics_complete", "height", "weight", "bmi", "comments", +"health_complete", "race", "race", "ethnicity", "interpreter_needed", +"race_and_ethnicity_complete", "record_id", "name_first", "name_last", +"demographics_complete"), value = c("1", "Nutmeg", "Nutmouse", "14 Rose Cottage St.\nKenning UK, 323232", "(405) 321-1111", -"nutty@mouse.com", "2003-08-30", "11", "0", "2", "7", "1", "Character in a book, with some guessing", -"1", "5", "1", "0", "2", "204.1", "2", "Tumtum", "Nutmouse", -"14 Rose Cottage Blvd.\nKenning UK 34243", "(405) 321-2222", -"tummy@mouse.comm", "2003-03-10", "11", "1", "2", "6", "1", "A mouse character from a good book", -"0", "3", "5", "1", "0", "0", "277.8", "3", "Marcus", "Wood", -"243 Hill St.\nGuthrie OK 73402", "(405) 321-3333", "mw@mwood.net", -"1934-04-09", "80", "1", "2", "180", "80", "completely made up", -"2", "4", "5", "0", "1", "2", "24.7", "4", "Trudy", "DAG", "342 Elm\nDuncanville TX, 75116", +"nutty@mouse.com", "2003-08-30", "11", "0", "2", "7", "1", "204.1", +"Character in a book, with some guessing", "1", "5", "1", "0", +"2", "2", "Tumtum", "Nutmouse", "14 Rose Cottage Blvd.\nKenning UK 34243", +"(405) 321-2222", "tummy@mouse.comm", "2003-03-10", "11", "1", +"2", "6", "1", "277.8", "A mouse character from a good book", +"0", "3", "5", "1", "0", "0", "3", "Marcus", "Wood", "243 Hill St.\nGuthrie OK 73402", +"(405) 321-3333", "mw@mwood.net", "1934-04-09", "80", "1", "2", +"180", "80", "24.7", "completely made up", "2", "4", "5", "0", +"1", "2", "4", "Trudy", "DAG", "342 Elm\nDuncanville TX, 75116", "(405) 321-4444", "peroxide@blonde.com", "1952-11-02", "61", -"0", "2", "165", "54", "This record doesn't have a DAG assigned\n\nSo call up Trudy on the telephone\nSend her a letter in the mail", -"2", "2", "5", "1", "2", "19.8", "5", "John Lee", "Walker", "Hotel Suite\nNew Orleans LA, 70115", +"0", "2", "165", "54", "19.8", "This record doesn't have a DAG assigned\n\nSo call up Trudy on the telephone\nSend her a letter in the mail", +"2", "2", "5", "1", "2", "5", "John Lee", "Walker", "Hotel Suite\nNew Orleans LA, 70115", "(405) 321-5555", "left@hippocket.com", "1955-04-15", "59", "1", -"2", "193.04", "104", "Had a hand for trouble and a eye for cash\n\nHe had a gold watch chain and a black mustache", -"0", "1", "6", "2", "0", "2", "27.9", "6", "blank-for-gray", -"blank-for-gray", "0", "0", "0")), row.names = c(NA, -104L), class = c("tbl_df", -"tbl", "data.frame")) +"2", "193.04", "104", "27.9", "Had a hand for trouble and a eye for cash\n\nHe had a gold watch chain and a black mustache", +"0", "1", "6", "2", "0", "2", "6", "blank-for-gray", "blank-for-gray", +"0")), row.names = c(NA, -102L), class = c("tbl_df", "tbl", "data.frame" +)) From fb2b6f91b63a2a15a888c052fea109cc5f419823 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 17 Oct 2024 14:49:35 -0500 Subject: [PATCH 16/21] null values for untouched checkboxes ref #542 --- .../read-eav-oneshot/blank-for-gray-false.R | 61 ++++++++++--------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/inst/test-data/specific-redcapr/read-eav-oneshot/blank-for-gray-false.R b/inst/test-data/specific-redcapr/read-eav-oneshot/blank-for-gray-false.R index 9d89ea96..3786c7f3 100644 --- a/inst/test-data/specific-redcapr/read-eav-oneshot/blank-for-gray-false.R +++ b/inst/test-data/specific-redcapr/read-eav-oneshot/blank-for-gray-false.R @@ -6,41 +6,42 @@ structure(list(record = c("1", "1", "1", "1", "1", "1", "1", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", -"6", "6", "6", "6", "6", "6"), field_name = c("record_id", "name_first", +"6", "6", "6", "6"), field_name = c("record_id", "name_first", "name_last", "address", "telephone", "email", "dob", "age", "sex", -"demographics_complete", "height", "weight", "comments", "health_complete", +"demographics_complete", "height", "weight", "bmi", "comments", +"health_complete", "race", "ethnicity", "interpreter_needed", +"race_and_ethnicity_complete", "record_id", "name_first", "name_last", +"address", "telephone", "email", "dob", "age", "sex", "demographics_complete", +"height", "weight", "bmi", "comments", "health_complete", "race", "race", "ethnicity", "interpreter_needed", "race_and_ethnicity_complete", -"bmi", "record_id", "name_first", "name_last", "address", "telephone", +"record_id", "name_first", "name_last", "address", "telephone", "email", "dob", "age", "sex", "demographics_complete", "height", -"weight", "comments", "health_complete", "race", "race", "ethnicity", -"interpreter_needed", "race_and_ethnicity_complete", "bmi", "record_id", -"name_first", "name_last", "address", "telephone", "email", "dob", -"age", "sex", "demographics_complete", "height", "weight", "comments", -"health_complete", "race", "race", "ethnicity", "interpreter_needed", -"race_and_ethnicity_complete", "bmi", "record_id", "name_first", -"name_last", "address", "telephone", "email", "dob", "age", "sex", -"demographics_complete", "height", "weight", "comments", "health_complete", -"race", "race", "ethnicity", "race_and_ethnicity_complete", "bmi", +"weight", "bmi", "comments", "health_complete", "race", "race", +"ethnicity", "interpreter_needed", "race_and_ethnicity_complete", "record_id", "name_first", "name_last", "address", "telephone", "email", "dob", "age", "sex", "demographics_complete", "height", -"weight", "comments", "health_complete", "race", "race", "ethnicity", -"interpreter_needed", "race_and_ethnicity_complete", "bmi", "record_id", -"name_first", "name_last", "demographics_complete", "health_complete", -"race_and_ethnicity_complete"), value = c("1", "Nutmeg", "Nutmouse", +"weight", "bmi", "comments", "health_complete", "race", "race", +"ethnicity", "race_and_ethnicity_complete", "record_id", "name_first", +"name_last", "address", "telephone", "email", "dob", "age", "sex", +"demographics_complete", "height", "weight", "bmi", "comments", +"health_complete", "race", "race", "ethnicity", "interpreter_needed", +"race_and_ethnicity_complete", "record_id", "name_first", "name_last", +"demographics_complete"), value = c("1", "Nutmeg", "Nutmouse", "14 Rose Cottage St.\nKenning UK, 323232", "(405) 321-1111", -"nutty@mouse.com", "2003-08-30", "11", "0", "2", "7", "1", "Character in a book, with some guessing", -"1", "5", "1", "0", "2", "204.1", "2", "Tumtum", "Nutmouse", -"14 Rose Cottage Blvd.\nKenning UK 34243", "(405) 321-2222", -"tummy@mouse.comm", "2003-03-10", "11", "1", "2", "6", "1", "A mouse character from a good book", -"0", "3", "5", "1", "0", "0", "277.8", "3", "Marcus", "Wood", -"243 Hill St.\nGuthrie OK 73402", "(405) 321-3333", "mw@mwood.net", -"1934-04-09", "80", "1", "2", "180", "80", "completely made up", -"2", "4", "5", "0", "1", "2", "24.7", "4", "Trudy", "DAG", "342 Elm\nDuncanville TX, 75116", +"nutty@mouse.com", "2003-08-30", "11", "0", "2", "7", "1", "204.1", +"Character in a book, with some guessing", "1", "5", "1", "0", +"2", "2", "Tumtum", "Nutmouse", "14 Rose Cottage Blvd.\nKenning UK 34243", +"(405) 321-2222", "tummy@mouse.comm", "2003-03-10", "11", "1", +"2", "6", "1", "277.8", "A mouse character from a good book", +"0", "3", "5", "1", "0", "0", "3", "Marcus", "Wood", "243 Hill St.\nGuthrie OK 73402", +"(405) 321-3333", "mw@mwood.net", "1934-04-09", "80", "1", "2", +"180", "80", "24.7", "completely made up", "2", "4", "5", "0", +"1", "2", "4", "Trudy", "DAG", "342 Elm\nDuncanville TX, 75116", "(405) 321-4444", "peroxide@blonde.com", "1952-11-02", "61", -"0", "2", "165", "54", "This record doesn't have a DAG assigned\n\nSo call up Trudy on the telephone\nSend her a letter in the mail", -"2", "2", "5", "1", "2", "19.8", "5", "John Lee", "Walker", "Hotel Suite\nNew Orleans LA, 70115", +"0", "2", "165", "54", "19.8", "This record doesn't have a DAG assigned\n\nSo call up Trudy on the telephone\nSend her a letter in the mail", +"2", "2", "5", "1", "2", "5", "John Lee", "Walker", "Hotel Suite\nNew Orleans LA, 70115", "(405) 321-5555", "left@hippocket.com", "1955-04-15", "59", "1", -"2", "193.04", "104", "Had a hand for trouble and a eye for cash\n\nHe had a gold watch chain and a black mustache", -"0", "1", "6", "2", "0", "2", "27.9", "6", "blank-for-gray", -"blank-for-gray", "0", "0", "0")), row.names = c(NA, -104L), class = c("tbl_df", -"tbl", "data.frame")) +"2", "193.04", "104", "27.9", "Had a hand for trouble and a eye for cash\n\nHe had a gold watch chain and a black mustache", +"0", "1", "6", "2", "0", "2", "6", "blank-for-gray", "blank-for-gray", +"0")), row.names = c(NA, -102L), class = c("tbl_df", "tbl", "data.frame" +)) From bc35fdb3b27b86290a3c09342b10249dafbeefd5 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 17 Oct 2024 15:28:08 -0500 Subject: [PATCH 17/21] null for untouched checboxes ref #542 --- .../specific-redcapr/read-batch-simple/blank-for-gray-true.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inst/test-data/specific-redcapr/read-batch-simple/blank-for-gray-true.R b/inst/test-data/specific-redcapr/read-batch-simple/blank-for-gray-true.R index 554e3c03..5cf858c6 100644 --- a/inst/test-data/specific-redcapr/read-batch-simple/blank-for-gray-true.R +++ b/inst/test-data/specific-redcapr/read-batch-simple/blank-for-gray-true.R @@ -17,10 +17,10 @@ NA), dob = structure(c(12294, 12121, -13051, -6269, -5375, NA "Had a hand for trouble and a eye for cash\n\nHe had a gold watch chain and a black mustache", NA), mugshot = c("mugshot-1.jpg", "mugshot-2.jpg", "mugshot-3.jpg", "mugshot-4.jpg", "mugshot-5.jpg", NA), health_complete = c(1, - 0, 2, 2, 0, 0), race___1 = c(0, 0, 0, 0, 1, 0), race___2 = c(0, + 0, 2, 2, 0, NA), race___1 = c(0, 0, 0, 0, 1, 0), race___2 = c(0, 0, 0, 1, 0, 0), race___3 = c(0, 1, 0, 0, 0, 0), race___4 = c(0, 0, 1, 0, 0, 0), race___5 = c(1, 1, 1, 1, 0, 0), race___6 = c(0, 0, 0, 0, 1, 0), ethnicity = c(1, 1, 0, 1, 2, NA), interpreter_needed = c(0, 0, 1, NA, 0, NA), race_and_ethnicity_complete = c(2, 0, 2, - 2, 2, 0)), row.names = c(NA, -6L), class = c("spec_tbl_df", + 2, 2, NA)), row.names = c(NA, -6L), class = c("spec_tbl_df", "tbl_df", "tbl", "data.frame")) From 460066250af000fd0b9b5cc769c24dbee9b46ade Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 17 Oct 2024 16:29:45 -0500 Subject: [PATCH 18/21] spaces around pipes ref #544 --- tests/testthat/test-metadata-read.R | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/testthat/test-metadata-read.R b/tests/testthat/test-metadata-read.R index 0702f869..76a8b8f0 100644 --- a/tests/testthat/test-metadata-read.R +++ b/tests/testthat/test-metadata-read.R @@ -7,6 +7,13 @@ credential_super_wide_3<-retrieve_credential_testing("super-wide-3") credential_problem <- retrieve_credential_testing("potentially-problematic-dictionary") update_expectation <- FALSE +if (credential$redcap_uri != "https://redcap-dev-2.ouhsc.edu/redcap/api/") { + testthat::skip("Skipping EAV test on non-dev server") + # The two servers have different outputs/spaces around the pipes. + # dev : "0, Female|1, Male" + # bbmc: "0, Female | 1, Male" +} + test_that("Smoke Test", { testthat::skip_on_cran() expect_message({ From 6630386f3f9eb010132d3502465d3ce998b97740 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 17 Oct 2024 16:57:18 -0500 Subject: [PATCH 19/21] restore incomplete state in survey project ref #542 --- inst/test-data/projects/survey/README.md | 16 +++++++++++++--- .../test-data/projects/survey/expected/default.R | 15 +++++++-------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/inst/test-data/projects/survey/README.md b/inst/test-data/projects/survey/README.md index dddaff8a..195209a4 100644 --- a/inst/test-data/projects/survey/README.md +++ b/inst/test-data/projects/survey/README.md @@ -1,9 +1,19 @@ survey =============== -Additional (manual) steps to establish the test project on a new server: +Additional (manual) steps to establish the test project on a new server. +I don't know how to preserve these states/values in the xml file. -1. The `prescreening_survey_timestamp` field needs to be set. - So for both records, click the "Open Survey" button +1. For records 1 & 2: + 1. The `prescreening_survey_timestamp` field needs to be set and + 1. For both records, click the "Open Survey" button (in the "Survey Options" dropdown) and submit. + +1. For record 1 only: + 1. Delete the entry for the "Participant Morale Questionnaire" + 1. Start a new entry for the "Participant Morale Questionnaire" + 1. Set it to "Incomplete" + 1. In the survey options dropdown box, select "Open survey" + 1. Click "Save & Return Later" + 1. In the Record Status Dashboard, verify the "Participant Morale Questionnaire" status is orange diff --git a/inst/test-data/projects/survey/expected/default.R b/inst/test-data/projects/survey/expected/default.R index f6e3fd1a..97b0d60c 100644 --- a/inst/test-data/projects/survey/expected/default.R +++ b/inst/test-data/projects/survey/expected/default.R @@ -7,12 +7,11 @@ NA), prescreening_survey_timestamp = structure(c(1728851970, NA), first_name = c(NA, NA), last_name = c(NA, NA), address = c(NA, NA), telephone_1 = c(NA, NA), ethnicity = c(NA, NA), race = c(NA, NA), sex = c(NA, NA), height = c(NA, NA), weight = c(NA, - NA), participant_info_survey_complete = c(0, 0), participant_morale_questionnaire_timestamp = structure(c(1728855063, - NA), class = c("POSIXct", "POSIXt"), tzone = "UTC"), pmq1 = c(NA, - NA), pmq2 = c(NA, NA), pmq3 = c(NA, NA), pmq4 = c(NA, NA), - participant_morale_questionnaire_complete = c(2, 0), complete_study = c(NA, - NA), withdraw_date = c(NA, NA), withdraw_reason = c(NA, NA - ), date_visit_4 = c(NA, NA), discharge_date_4 = c(NA, NA), - discharge_summary_4 = c(NA, NA), study_comments = c(NA, NA - ), completion_data_complete = c(0, 0)), row.names = c(NA, + NA), participant_info_survey_complete = c(0, 0), participant_morale_questionnaire_timestamp = c("[not completed]", + NA), pmq1 = c(NA, NA), pmq2 = c(NA, NA), pmq3 = c(NA, NA), + pmq4 = c(NA, NA), participant_morale_questionnaire_complete = c(0, + 0), complete_study = c(NA, NA), withdraw_date = c(NA, NA), + withdraw_reason = c(NA, NA), date_visit_4 = c(NA, NA), discharge_date_4 = c(NA, + NA), discharge_summary_4 = c(NA, NA), study_comments = c(NA, + NA), completion_data_complete = c(0, 0)), row.names = c(NA, -2L), class = c("spec_tbl_df", "tbl_df", "tbl", "data.frame")) From f763ae5f332e4bdd3631ec59890235ca67132466 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 17 Oct 2024 17:09:28 -0500 Subject: [PATCH 20/21] allow different survey timestamps ref #544 --- .../projects/survey/expected/default.R | 10 ++++---- tests/testthat/test-read-batch-survey.R | 24 +++++++++++++++---- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/inst/test-data/projects/survey/expected/default.R b/inst/test-data/projects/survey/expected/default.R index 97b0d60c..df7fcdd4 100644 --- a/inst/test-data/projects/survey/expected/default.R +++ b/inst/test-data/projects/survey/expected/default.R @@ -1,9 +1,7 @@ structure(list(participant_id = c(1, 2), redcap_survey_identifier = c(NA, -NA), prescreening_survey_timestamp = structure(c(1728851970, -1728852051), class = c("POSIXct", "POSIXt"), tzone = "UTC"), - dob = structure(c(17596, 17595), class = "Date"), email = c("aaa@bbb.com", - "ccc@ddd.com"), has_diabetes = c(1, 0), consent___1 = c(1, - 0), prescreening_survey_complete = c(2, 2), participant_info_survey_timestamp = c(NA, +NA), dob = structure(c(17596, 17595), class = "Date"), email = c("aaa@bbb.com", +"ccc@ddd.com"), has_diabetes = c(1, 0), consent___1 = c(1, 0), + prescreening_survey_complete = c(2, 2), participant_info_survey_timestamp = c(NA, NA), first_name = c(NA, NA), last_name = c(NA, NA), address = c(NA, NA), telephone_1 = c(NA, NA), ethnicity = c(NA, NA), race = c(NA, NA), sex = c(NA, NA), height = c(NA, NA), weight = c(NA, @@ -14,4 +12,4 @@ NA), prescreening_survey_timestamp = structure(c(1728851970, withdraw_reason = c(NA, NA), date_visit_4 = c(NA, NA), discharge_date_4 = c(NA, NA), discharge_summary_4 = c(NA, NA), study_comments = c(NA, NA), completion_data_complete = c(0, 0)), row.names = c(NA, --2L), class = c("spec_tbl_df", "tbl_df", "tbl", "data.frame")) +-2L), class = c("tbl_df", "tbl", "data.frame")) diff --git a/tests/testthat/test-read-batch-survey.R b/tests/testthat/test-read-batch-survey.R index 54bf3397..9be4d6fb 100644 --- a/tests/testthat/test-read-batch-survey.R +++ b/tests/testthat/test-read-batch-survey.R @@ -62,11 +62,18 @@ test_that("default", { verbose = FALSE ) - if (update_expectation) save_expected(returned_object1$data, path_expected) + expect_true(all(!is.na(returned_object1$data$prescreening_survey_timestamp))) + expect_s3_class(returned_object1$data$prescreening_survey_timestamp, "POSIXct") + d1 <- + returned_object1$data |> + dplyr::select( + -prescreening_survey_timestamp + ) + + if (update_expectation) save_expected(d1, path_expected) expected_data_frame <- retrieve_expected(path_expected) - expect_equal(returned_object1$data, expected=expected_data_frame, label="The returned data.frame should be correct", ignore_attr = TRUE) # dput(returned_object1$data) - expect_true(all(!is.na(returned_object1$data$prescreening_survey_timestamp))) + expect_equal(d1, expected=expected_data_frame, label="The returned data.frame should be correct", ignore_attr = TRUE) # dput(returned_object1$data) expect_true(returned_object1$success) expect_match(returned_object1$status_codes, regexp="200", perl=TRUE) expect_true(returned_object1$records_collapsed=="", "A subset of records was not requested.") @@ -86,8 +93,15 @@ test_that("default", { verbose = FALSE ) - expect_equal(returned_object2$data, expected=expected_data_frame, label="The returned data.frame should be correct", ignore_attr = TRUE) # dput(returned_object2$data) - expect_true(all(!is.na(returned_object1$data$prescreening_survey_timestamp))) + expect_true(all(!is.na(returned_object2$data$prescreening_survey_timestamp))) + expect_s3_class(returned_object2$data$prescreening_survey_timestamp, "POSIXct") + d2 <- + returned_object2$data |> + dplyr::select( + -prescreening_survey_timestamp + ) + + expect_equal(d2, expected=expected_data_frame, label="The returned data.frame should be correct", ignore_attr = TRUE) # dput(returned_object2$data) expect_true(returned_object2$success) expect_match(returned_object2$status_codes, regexp="200", perl=TRUE) expect_true(returned_object2$records_collapsed=="", "A subset of records was not requested.") From dcdcd24eb61c2f2bb013766d34099a2b53aa4c31 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Thu, 17 Oct 2024 17:24:12 -0500 Subject: [PATCH 21/21] test work on both servers now close #544 --- NEWS.md | 2 +- inst/test-data/projects/README.md | 1 + tests/test-all.R | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index a9046457..8e20f056 100644 --- a/NEWS.md +++ b/NEWS.md @@ -17,7 +17,7 @@ These features are not yet on CRAN. Install with `remotes::install_github("Ouhs ### Minor Enhancements -* Redirection layer for test suite allows you to plug in your own server (#539) +* Redirection layer for test suite allows you to plug in your own server (#539, #542, #544) Version 1.2.0 (released 2024-09-08) ========================================================== diff --git a/inst/test-data/projects/README.md b/inst/test-data/projects/README.md index a139872f..5f7c8243 100644 --- a/inst/test-data/projects/README.md +++ b/inst/test-data/projects/README.md @@ -8,3 +8,4 @@ Steps to recreate on a fresh server Tests are case-sensitive. 1. 'unittestphifree': First name = "Unit Test"; Last name "Phi Free". 1. 'unittestphifree-dag1': First name = "Unit Test"; Last name "PHI Free DAG1" +1. Install plugins diff --git a/tests/test-all.R b/tests/test-all.R index 0b1d105d..5fb4d7df 100644 --- a/tests/test-all.R +++ b/tests/test-all.R @@ -2,8 +2,8 @@ library(testthat) library(REDCapR) -# Sys.setenv("redcapr_test_server" = "dev-2") -Sys.setenv("redcapr_test_server" = "bbmc") +Sys.setenv("redcapr_test_server" = "dev-2") +# Sys.setenv("redcapr_test_server" = "bbmc") message("Using test server '", Sys.getenv("redcapr_test_server"), "'.")