Skip to content

Commit

Permalink
restore local credential tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wibeasley committed Oct 13, 2024
1 parent ce0c665 commit 5afb681
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions inst/misc/bad.credentials
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# are stored securely.
#
redcap_uri,username,project_id,token,comment
"http://bbmc.ouhsc.edu/redcap/api/","myusername","33","9A81268476645C4E5F03428B8A","simple static (read-only) test project"
"https://bbmc.ouhsc.edu/redcap/api/","myusername","34","D70F9ACD1EDD6F151C6EA78683944E98","simple write data"
"https://redcap-dev-2.ouhsc.edu/redcap/api/","myusername","33","9A068","simple static (read-only) test project"
"http://redcap-dev-2.ouhsc.edu/redcap/api/","myusername","34","F9CBFFF78C3D78F641BAE9623F6B7E6A","simple write data"
22 changes: 11 additions & 11 deletions tests/testthat/test-retrieve-credential-local.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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_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.

Expand Down Expand Up @@ -80,7 +80,7 @@ test_that("Missing file", {

expect_error(
regexp = expected_message,
object = REDCapR::retrieve_credential_local(
object = retrieve_credential_local(
path_credential = "misc/missing.credentials", #system.file("misc/missing.credentials", package="REDCapR"),
project_id = pid_read
)
Expand All @@ -91,7 +91,7 @@ test_that("Malformed file", {

expect_error(
regexp = expected_message,
object = REDCapR::retrieve_credential_local(
object = retrieve_credential_local(
path_credential = system.file("misc/out-of-order.credentials", package="REDCapR"),
project_id = pid_read
)
Expand All @@ -102,7 +102,7 @@ test_that("Zero rows", {

expect_error(
regexp = expected_message,
object = REDCapR::retrieve_credential_local(
object = retrieve_credential_local(
path_credential = system.file("misc/zero-rows.credentials", package="REDCapR"),
project_id = 666L
)
Expand All @@ -113,7 +113,7 @@ test_that("Zero matching rows", {

expect_error(
regexp = expected_message,
object = REDCapR::retrieve_credential_local(
object = retrieve_credential_local(
path_credential = path,
project_id = 666L
)
Expand All @@ -124,7 +124,7 @@ test_that("Conflicting rows", {

expect_error(
regexp = expected_message,
object = REDCapR::retrieve_credential_local(
object = retrieve_credential_local(
path_credential = system.file("misc/conflicting-rows.credentials", package="REDCapR"),
project_id = pid_read
)
Expand All @@ -135,9 +135,9 @@ test_that("Bad URI", {

expect_error(
regexp = expected_message,
object = REDCapR::retrieve_credential_local(
object = retrieve_credential_local(
path_credential = system.file("misc/bad.credentials", package="REDCapR"),
project_id = pid_read,
project_id = pid_longitudinal,
check_url = TRUE,
check_username = FALSE,
check_token_pattern = FALSE
Expand All @@ -149,7 +149,7 @@ test_that("Bad Username", {

expect_error(
regexp = expected_message,
object = REDCapR::retrieve_credential_local(
object = retrieve_credential_local(
path_credential = system.file("misc/bad.credentials", package="REDCapR"),
project_id = pid_read,
check_url = FALSE,
Expand All @@ -158,12 +158,12 @@ test_that("Bad Username", {
)
)
})
test_that("Bad URI", {
test_that("Bad token", {
expected_message <- "A REDCap token should be a string of 32 digits and uppercase characters. The retrieved value was not. Set the `check_token_pattern` parameter to FALSE if you're sure you have the correct file & file contents."

expect_error(
regexp = expected_message,
object = REDCapR::retrieve_credential_local(
object = retrieve_credential_local(
path_credential = system.file("misc/bad.credentials", package="REDCapR"),
project_id = pid_read,
check_url = FALSE,
Expand Down
2 changes: 1 addition & 1 deletion utility/refresh.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ devtools::run_examples(); #dev.off() #This overwrites the NAMESPACE file too
# devtools::run_examples(, "redcap_read.Rd")
# pkgload::load_all()
test_results_checked <- devtools::test()
test_results_checked <- devtools::test(filter = "^validate")
test_results_checked <- devtools::test(filter = "^retrieve-credential")
# withr::local_envvar(ONLYREADTESTS = "true")
# test_results_checked <- devtools::test(filter = "write-batch")

Expand Down

0 comments on commit 5afb681

Please sign in to comment.