Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/OuhscBbmc/REDCapR into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
wibeasley committed Jul 14, 2023
2 parents abb9100 + 70fafd7 commit e0a1451
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ This will help extract forms from longitudinal & repeating projects.
* `validate_repeat_instance()`
* `validate_no_logical()`
* `redcap_read()` checks the `event` parameter and throws an error if a value is not recognized, or the project is not longitudinal (#493)
* The regex in `regex_named_captures()` is forgiving if there's an unnecessary leading space (@BlairCooper, #495)
Version 1.1.0 (released 2022-08-10)
==========================================================
Expand Down
2 changes: 1 addition & 1 deletion R/metadata-utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
regex_named_captures <- function(pattern, text, perl = TRUE) {
checkmate::assert_character(pattern, any.missing=FALSE, min.chars=0L, len=1)
checkmate::assert_character(text , any.missing=FALSE, min.chars=0L, len=1)
checkmate::assert_logical( perl , any.missing=FALSE)
checkmate::assert_logical( perl , any.missing=FALSE , len=1)

match <- gregexpr(pattern, text, perl = perl)[[1]]
capture_names <- attr(match, "capture.names")
Expand Down
20 changes: 4 additions & 16 deletions tests/testthat/test-read-errors.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,17 @@ test_that("One Shot: Bad Uri -Not HTTPS", {
# expected_message_501 <- "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><hash><error>The requested method is not implemented.</error></hash>"

expect_error(
# returned_object <-
redcap_read_oneshot(
redcap_uri = "http://bbmc.ouhsc.edu/redcap/api/", # Not HTTPS
token = credential$token
)
redcap_read_oneshot(
redcap_uri = "http://bbmc.ouhsc.edu/redcap/api/", # Not HTTPS
token = credential$token
)
)

# expect_equal(returned_object$data, expected=data.frame(), label="An empty data.frame should be returned.")
# expect_true(returned_object$status_code %in% c(411L, 501L))
# expect_true(returned_object$raw_text %in% c(expected_message_411, expected_message_501))
# # expect_equal(returned_object$raw_text, expected=expected_message)
# expect_equal(returned_object$records_collapsed, "")
# expect_equal(returned_object$fields_collapsed, "")
# expect_false(returned_object$success)
})

test_that("One Shot: Bad Uri -wrong address", {
testthat::skip_on_cran()
expected_message <- "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>404 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p>The requested URL was not found on this server.</p>\n</body></html>\n"

# expected_outcome_message <- "The initial call failed with the code: 404."
# expected_outcome_message <- "The requested URL was not found on this server."

returned_object <-
redcap_read_oneshot(
redcap_uri = "https://bbmc.ouhsc.edu/redcap/apiFFFFFFFFFFFFFF/", # Wrong url
Expand Down

0 comments on commit e0a1451

Please sign in to comment.