Skip to content

Commit

Permalink
deprecated testthat::expect_equivalent()
Browse files Browse the repository at this point in the history
pattern = `expect_equivalent\(([^\\)]+)\)`
replace = `expect_equal($1, ignore_attr = TRUE)`

ref #312
  • Loading branch information
wibeasley committed Nov 19, 2020
1 parent 0718680 commit 298d9af
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 73 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ VignetteBuilder: knitr
Encoding: UTF-8
RoxygenNote: 7.1.1
Roxygen: list(markdown = TRUE)
Config/testthat/edition: 3
4 changes: 2 additions & 2 deletions tests/manual/test-stress-test-serial.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ for( i in seq_len(read_count) ) {

expect_equal(returned_object$data, expected=expected_data_frame, label="The returned data.frame should be correct") # dput(returned_object$data)
expect_equal(returned_object$status_code, expected=200L)
expect_equivalent(returned_object$raw_text, expected="") # dput(returned_object$raw_text)
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object$raw_text)
expect_true(returned_object$records_collapsed=="", "A subset of records was not requested.")
expect_true(returned_object$fields_collapsed=="", "A subset of fields was not requested.")
expect_match(returned_object$outcome_message, regexp=expected_outcome_message, perl=TRUE)
Expand Down Expand Up @@ -110,7 +110,7 @@ for( i in seq_len(file_count) ) {
expect_equal(returned_object$records_affected_count, 1L)
expect_equal(returned_object$affected_ids, 1L)
expect_true(returned_object$elapsed_seconds>0, "The `elapsed_seconds` should be a positive number.")
expect_equivalent(returned_object$raw_text, expected="") # dput(returned_object$raw_text)
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object$raw_text)
expect_equal(returned_object$file_name, "mugshot-1.jpg", label="The name of the downloaded file should be correct.")

#Test the values of the file.
Expand Down
21 changes: 11 additions & 10 deletions tests/testthat/test-file-oneshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ test_that("NameComesFromREDCap", {
record <- 1
field <- "mugshot"

expected_outcome_message <- '; name="mugshot-1\\.jpg" successfully downloaded in \\d+(\\.\\d+\\W|\\W)seconds\\, and saved as mugshot-1.jpg'
expected_outcome_message <- '^(Preparing to download the file `mugshot-1.jpg`\\.|.+; name="mugshot-1\\.jpg" successfully downloaded in \\d+(\\.\\d+\\W|\\W)seconds\\, and saved as mugshot-1.jpg)'

expected_outcome_message <- ".+"
tryCatch({
expect_message(
capture_messages(
returned_object <- redcap_download_file_oneshot(
record = record,
field = field,
redcap_uri = credential$redcap_uri,
token = credential$token,
),
regexp = expected_outcome_message
token = credential$token
)#,
# regexp = NA #expected_outcome_message
)
Sys.sleep(delay_after_download_file)

Expand All @@ -39,7 +40,7 @@ test_that("NameComesFromREDCap", {
expect_equal(returned_object$records_affected_count, 1L)
expect_equal(returned_object$affected_ids, "1")
expect_true(returned_object$elapsed_seconds>0, "The `elapsed_seconds` should be a positive number.")
expect_equivalent(returned_object$raw_text, expected="") # dput(returned_object$raw_text)
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object$raw_text)
expect_equal(returned_object$file_name, "mugshot-1.jpg", label="The name of the downloaded file should be correct.")

#Test the values of the file.
Expand Down Expand Up @@ -88,7 +89,7 @@ test_that("FullPathSpecified", {
expect_equal(returned_object$records_affected_count, 1L)
expect_equal(returned_object$affected_ids, "2")
expect_true(returned_object$elapsed_seconds>0, "The `elapsed_seconds` should be a positive number.")
expect_equivalent(returned_object$raw_text, expected="") # dput(returned_object$raw_text)
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object$raw_text)
expect_equal(returned_object$file_name, full_name, label="The name of the downloaded file should be correct.")

#Test the values of the file.
Expand Down Expand Up @@ -137,7 +138,7 @@ test_that("RelativePath", {
expect_equal(returned_object$records_affected_count, 1L)
expect_equal(returned_object$affected_ids, "3")
expect_true(returned_object$elapsed_seconds>0, "The `elapsed_seconds` should be a positive number.")
expect_equivalent(returned_object$raw_text, expected="") # dput(returned_object$raw_text)
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object$raw_text)
expect_equal(returned_object$file_name, relative_name, label="The name of the downloaded file should be correct.")

#Test the values of the file.
Expand Down Expand Up @@ -186,7 +187,7 @@ test_that("Full Directory Specific", {
expect_equal(returned_object$records_affected_count, 1L)
expect_equal(returned_object$affected_ids, "3")
expect_true(returned_object$elapsed_seconds>0, "The `elapsed_seconds` should be a positive number.")
expect_equivalent(returned_object$raw_text, expected="") # dput(returned_object$raw_text)
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object$raw_text)
expect_equal(returned_object$file_name, returned_object$file_name, label="The name of the downloaded file should be correct.")

#Test the values of the file.
Expand Down Expand Up @@ -281,7 +282,7 @@ test_that("Download Error --bad field name", {
expect_equal(returned_object$records_affected_count, 0L)
expect_equal(returned_object$affected_ids, character(0))
expect_true(returned_object$elapsed_seconds>0, "The `elapsed_seconds` should be a positive number.")
expect_equivalent(returned_object$raw_text, expected=expected_raw_text) # dput(returned_object$raw_text)
expect_equal(returned_object$raw_text, expected=expected_raw_text, ignore_attr = TRUE) # dput(returned_object$raw_text)
expect_null(returned_object$file_name, label="The name of the downloaded file should be correct.")
})

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-instrument.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ test_that("download instrument", {
expect_match(returned_object$outcome_message, regexp=expected_outcome_message, perl=TRUE)
expect_equal(length(returned_object$record_id), 0L)
expect_true(returned_object$elapsed_seconds>0, "The `elapsed_seconds` should be a positive number.")
expect_equivalent(returned_object$raw_text, expected="") # dput(returned_object$raw_text)
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object$raw_text)
expect_equal(returned_object$file_name, "instruments.pdf", label="The name of the downloaded file should be correct.")
})

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-metadata-read.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ test_that("normal", {
# datapasta::tribble_paste(returned_object$data)
expect_equal(returned_object$data, expected=expected_data_frame, label="The returned data.frame should be correct") # dput(returned_object$data)
expect_equal(returned_object$status_code, expected=200L)
expect_equivalent(returned_object$raw_text, expected="") # dput(returned_object$raw_text)
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object$raw_text)
expect_true(returned_object$forms_collapsed=="", "A subset of forms was not requested.")
expect_true(returned_object$fields_collapsed=="", "A subset of fields was not requested.")
expect_match(returned_object$outcome_message, regexp=expected_outcome_message, perl=TRUE)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-read-batch-simple.R
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ test_that("label-header", {
if (update_expectation) save_expected(returned_object$data, path_expected)
expected_data_frame <- retrieve_expected(path_expected)

expect_equivalent(returned_object$data, expected=expected_data_frame, label="The returned data.frame should be correct") # dput(returned_object$data)
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(returned_object$status_codes, regexp="200", perl=TRUE)
expect_true(returned_object$records_collapsed=="", "A subset of records was not requested.")
expect_true(returned_object$fields_collapsed=="", "A subset of fields was not requested.")
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-read-batch-survey.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ test_that("default", {
if (update_expectation) save_expected(returned_object1$data, path_expected)
expected_data_frame <- retrieve_expected(path_expected)

expect_equivalent(returned_object1$data, expected=expected_data_frame, label="The returned data.frame should be correct") # dput(returned_object1$data)
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_true(returned_object1$success)
expect_match(returned_object1$status_codes, regexp="200", perl=TRUE)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-read-clinical-trial.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ test_that("default", {
if (update_expectation) save_expected(returned_object$data, path_expected)
expected_data_frame <- retrieve_expected(path_expected)

expect_equivalent(returned_object$data, expected=expected_data_frame, label="The returned data.frame should be correct") # dput(returned_object$data)
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_equal(returned_object$status_code, expected=200L)
expect_equivalent(returned_object$raw_text, expected="") # dput(returned_object$raw_text)
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object$raw_text)
expect_true(returned_object$records_collapsed=="", "A subset of records was not requested.")
expect_true(returned_object$fields_collapsed=="", "A subset of fields was not requested.")
expect_true(returned_object$filter_logic=="", "A filter was not specified.")
Expand Down
18 changes: 9 additions & 9 deletions tests/testthat/test-read-oneshot-eav.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test_that("default", {

expect_equal(returned_object$data, expected=expected_data_frame) # dput(returned_object$data)
expect_equal(returned_object$status_code, expected=200L)
expect_equivalent(returned_object$raw_text, expected="") # dput(returned_object$raw_text)
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object$raw_text)
expect_true(returned_object$records_collapsed=="", "A subset of records was not requested.")
expect_true(returned_object$fields_collapsed=="", "A subset of fields was not requested.")
expect_true(returned_object$filter_logic=="", "A filter was not specified.")
Expand All @@ -50,7 +50,7 @@ test_that("specify-forms", {

expect_equal(returned_object$data, expected=expected_data_frame) # dput(returned_object$data)
expect_equal(returned_object$status_code, expected=200L)
expect_equivalent(returned_object$raw_text, expected="") # dput(returned_object$raw_text)
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object$raw_text)
expect_true(returned_object$records_collapsed=="", "A subset of records was not requested.")
expect_true(returned_object$fields_collapsed=="", "A subset of fields was not requested.")
expect_true(returned_object$filter_logic=="", "A filter was not specified.")
Expand All @@ -74,7 +74,7 @@ test_that("raw", {

expect_equal(returned_object$data, expected=expected_data_frame, label="The returned data.frame should be correct") # dput(returned_object$data)
expect_equal(returned_object$status_code, expected=200L)
expect_equivalent(returned_object$raw_text, expected="") # dput(returned_object$raw_text)
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object$raw_text)
expect_true(returned_object$records_collapsed=="", "A subset of records was not requested.")
expect_true(returned_object$fields_collapsed=="", "A subset of fields was not requested.")
expect_true(returned_object$filter_logic=="", "A filter was not specified.")
Expand All @@ -96,7 +96,7 @@ test_that("raw-and-dag", {

expect_equal(returned_object$data, expected=expected_data_frame, label="The returned data.frame should be correct") # dput(returned_object$data)
expect_equal(returned_object$status_code, expected=200L)
expect_equivalent(returned_object$raw_text, expected="") # dput(returned_object$raw_text)
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object$raw_text)
expect_true(returned_object$records_collapsed=="", "A subset of records was not requested.")
expect_true(returned_object$fields_collapsed=="", "A subset of fields was not requested.")
expect_true(returned_object$filter_logic=="", "A filter was not specified.")
Expand All @@ -118,7 +118,7 @@ test_that("label-and-dag", {

expect_equal(returned_object$data, expected=expected_data_frame, label="The returned data.frame should be correct") # dput(returned_object$data)
expect_equal(returned_object$status_code, expected=200L)
expect_equivalent(returned_object$raw_text, expected="") # dput(returned_object$raw_text)
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object$raw_text)
expect_true(returned_object$records_collapsed=="", "A subset of records was not requested.")
expect_true(returned_object$fields_collapsed=="", "A subset of fields was not requested.")
expect_true(returned_object$filter_logic=="", "A filter was not specified.")
Expand All @@ -139,9 +139,9 @@ test_that("label-header", {
if (update_expectation) save_expected(returned_object$data, path_expected)
expected_data_frame <- retrieve_expected(path_expected)

expect_equivalent(returned_object$data, expected=expected_data_frame, label="The returned data.frame should be correct") # dput(returned_object$data)
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_equal(returned_object$status_code, expected=200L)
expect_equivalent(returned_object$raw_text, expected="") # dput(returned_object$raw_text)
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object$raw_text)
expect_true(returned_object$records_collapsed=="", "A subset of records was not requested.")
expect_true(returned_object$fields_collapsed=="", "A subset of fields was not requested.")
expect_true(returned_object$filter_logic=="", "A filter was not specified.")
Expand All @@ -164,7 +164,7 @@ test_that("filter-numeric", {

expect_equal(returned_object$data, expected=expected_data_frame, label="The returned data.frame should be correct") # dput(returned_object$data)
expect_equal(returned_object$status_code, expected=200L)
expect_equivalent(returned_object$raw_text, expected="") # dput(returned_object$raw_text)
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object$raw_text)
expect_true(returned_object$records_collapsed=="", "A subset of records was not requested.")
expect_true(returned_object$fields_collapsed=="", "A subset of fields was not requested.")
expect_equal(returned_object$filter_logic, filter, "The filter was not correct.")
Expand All @@ -190,7 +190,7 @@ test_that("filter-character", {

expect_equal(returned_object$data, expected=expected_data_frame, label="The returned data.frame should be correct") # dput(returned_object$data)
expect_equal(returned_object$status_code, expected=200L)
expect_equivalent(returned_object$raw_text, expected="") # dput(returned_object$raw_text)
expect_equal(returned_object$raw_text, expected="", ignore_attr = TRUE) # dput(returned_object$raw_text)
expect_true(returned_object$records_collapsed=="", "A subset of records was not requested.")
expect_true(returned_object$fields_collapsed=="", "A subset of fields was not requested.")
expect_equal(returned_object$filter_logic, filter, "The filter was not correct.")
Expand Down
Loading

0 comments on commit 298d9af

Please sign in to comment.