diff --git a/tests/testthat.R b/tests/testthat.R index 589b398..972de0b 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -1,2 +1,8 @@ library("testthat") -#test_check("dataverse") +local({ + library("dataverse") + dv_server <- Sys.getenv("DATAVERSE_SERVER") + on.exit(Sys.setenv("DATAVERSE_SERVER" = dv_server)) + Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu") + #test_check("dataverse") +}) diff --git a/tests/testthat/dataAccess.R b/tests/testthat/dataAccess.R deleted file mode 100644 index 78a3d0c..0000000 --- a/tests/testthat/dataAccess.R +++ /dev/null @@ -1,7 +0,0 @@ -context("Data Access API") - -Sys.setenv("DATAVERSE_SERVER" = "demo.dataverse.org") - -test_that("placeholder", { - expect_true(TRUE) -}) diff --git a/tests/testthat/nativeAPI.R b/tests/testthat/nativeAPI.R deleted file mode 100644 index 7610ebf..0000000 --- a/tests/testthat/nativeAPI.R +++ /dev/null @@ -1,7 +0,0 @@ -context("Native API") - -Sys.setenv("DATAVERSE_SERVER" = "demo.dataverse.org") - -test_that("placeholder", { - expect_true(TRUE) -}) diff --git a/tests/testthat/search.R b/tests/testthat/search.R deleted file mode 100644 index cc4ea65..0000000 --- a/tests/testthat/search.R +++ /dev/null @@ -1,7 +0,0 @@ -context("Search API") - -Sys.setenv("DATAVERSE_SERVER" = "demo.dataverse.org") - -test_that("placeholder", { - expect_true(TRUE) -}) diff --git a/tests/testthat/sword.R b/tests/testthat/sword.R deleted file mode 100644 index d206b13..0000000 --- a/tests/testthat/sword.R +++ /dev/null @@ -1,7 +0,0 @@ -context("SWORD API") - -Sys.setenv("DATAVERSE_SERVER" = "demo.dataverse.org") - -test_that("placeholder", { - expect_true(TRUE) -}) diff --git a/tests/testthat/tests-dataAccess.R b/tests/testthat/tests-dataAccess.R new file mode 100644 index 0000000..5e3b634 --- /dev/null +++ b/tests/testthat/tests-dataAccess.R @@ -0,0 +1,21 @@ +context("Data Access API") + +test_that("get file metadata from DOI and filename", { + f1 <- get_metadata("constructionData.tab", "doi:10.7910/DVN/ARKOTI", server = "dataverse.harvard.edu") + expect_true(is.list(f1)) +}) + +test_that("get file metadata from file id", { + f1 <- get_metadata(2692202, server = "dataverse.harvard.edu") + expect_true(is.list(f1)) +}) + +test_that("download file from DOI and filename", { + f1 <- get_file("constructionData.tab", "doi:10.7910/DVN/ARKOTI", server = "dataverse.harvard.edu") + expect_true(is.raw(f1)) +}) + +test_that("download file from file id", { + f2 <- get_file(2692202, server = "dataverse.harvard.edu") + expect_true(is.raw(f2)) +}) diff --git a/tests/testthat/tests-nativeAPI.R b/tests/testthat/tests-nativeAPI.R new file mode 100644 index 0000000..b4441d5 --- /dev/null +++ b/tests/testthat/tests-nativeAPI.R @@ -0,0 +1,13 @@ +if (Sys.getenv("DATAVERSE_KEY") != "") { + context("Native API (authenticated functions)") + + test_that("placeholder", { + expect_true(TRUE) + }) +} + +context("Native API (unauthenticated functions)") + +test_that("placeholder", { + expect_true(TRUE) +}) diff --git a/tests/testthat/tests-search.R b/tests/testthat/tests-search.R new file mode 100644 index 0000000..8eb360f --- /dev/null +++ b/tests/testthat/tests-search.R @@ -0,0 +1,17 @@ +context("Search API") + +if (Sys.getenv("DATAVERSE_KEY") != "") { + + test_that("simple search query", { + expect_true(is.data.frame(dataverse_search("Gary King"))) + }) + + test_that("named argument search", { + expect_true(is.data.frame(dataverse_search(author = "Gary King", title = "Ecological Inference"))) + }) + + test_that("simple search w/type argument", { + expect_true(is.data.frame(dataverse_search(author = "Gary King", type = "dataset"))) + }) + +} diff --git a/tests/testthat/tests-sword.R b/tests/testthat/tests-sword.R new file mode 100644 index 0000000..171ddb1 --- /dev/null +++ b/tests/testthat/tests-sword.R @@ -0,0 +1,7 @@ +context("SWORD API") + +if (Sys.getenv("DATAVERSE_KEY") != "") { + test_that("placeholder", { + expect_true(TRUE) + }) +}