Skip to content

Commit

Permalink
expand test suite (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
leeper committed Apr 5, 2016
1 parent 2f31967 commit ea23685
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 29 deletions.
8 changes: 7 additions & 1 deletion tests/testthat.R
Original file line number Diff line number Diff line change
@@ -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")
})
7 changes: 0 additions & 7 deletions tests/testthat/dataAccess.R

This file was deleted.

7 changes: 0 additions & 7 deletions tests/testthat/nativeAPI.R

This file was deleted.

7 changes: 0 additions & 7 deletions tests/testthat/search.R

This file was deleted.

7 changes: 0 additions & 7 deletions tests/testthat/sword.R

This file was deleted.

21 changes: 21 additions & 0 deletions tests/testthat/tests-dataAccess.R
Original file line number Diff line number Diff line change
@@ -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))
})
13 changes: 13 additions & 0 deletions tests/testthat/tests-nativeAPI.R
Original file line number Diff line number Diff line change
@@ -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)
})
17 changes: 17 additions & 0 deletions tests/testthat/tests-search.R
Original file line number Diff line number Diff line change
@@ -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")))
})

}
7 changes: 7 additions & 0 deletions tests/testthat/tests-sword.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
context("SWORD API")

if (Sys.getenv("DATAVERSE_KEY") != "") {
test_that("placeholder", {
expect_true(TRUE)
})
}

0 comments on commit ea23685

Please sign in to comment.