Skip to content

Commit

Permalink
uncomment handle errors test, see what travis does, #52
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Jan 9, 2018
1 parent 99f7358 commit 03f5096
Showing 1 changed file with 52 additions and 52 deletions.
104 changes: 52 additions & 52 deletions tests/testthat/test-handle_errors.R
Expand Up @@ -21,72 +21,72 @@ gnp <- function(u) {
}


# test_that("badArgument is triggered", {
# skip_on_cran()
test_that("badArgument is triggered", {
skip_on_cran()

# xml <- gnp(error_url$badArgument)
# expect_error( handle_errors(xml) )
# expect_true( tryCatch( handle_errors(xml), error=function(er) inherits(er, "oai-pmh_error") ) )
# expect_true( tryCatch( handle_errors(xml), error=function(er) "badArgument" %in% attr(er, "error_codes")))
# } )
xml <- gnp(error_url$badArgument)
expect_error( handle_errors(xml) )
expect_true( tryCatch( handle_errors(xml), error=function(er) inherits(er, "oai-pmh_error") ) )
expect_true( tryCatch( handle_errors(xml), error=function(er) "badArgument" %in% attr(er, "error_codes")))
} )


# test_that("badResumptionToken is triggered", {
# skip_on_cran()
test_that("badResumptionToken is triggered", {
skip_on_cran()

# xml <- gnp(error_url$badResumptionToken)
# expect_error( handle_errors(xml) )
# expect_true( tryCatch( handle_errors(xml), error=function(er) inherits(er, "oai-pmh_error") ) )
# expect_true( tryCatch( handle_errors(xml), error=function(er) "badResumptionToken" %in% attr(er, "error_codes")))
# } )
xml <- gnp(error_url$badResumptionToken)
expect_error( handle_errors(xml) )
expect_true( tryCatch( handle_errors(xml), error=function(er) inherits(er, "oai-pmh_error") ) )
expect_true( tryCatch( handle_errors(xml), error=function(er) "badResumptionToken" %in% attr(er, "error_codes")))
} )

# test_that("badVerb is triggered", {
# skip_on_cran()
test_that("badVerb is triggered", {
skip_on_cran()

# xml <- gnp(error_url$badVerb)
# expect_error( handle_errors(xml) )
# expect_true( tryCatch( handle_errors(xml), error=function(er) inherits(er, "oai-pmh_error") ) )
# expect_true( tryCatch( handle_errors(xml), error=function(er) "badVerb" %in% attr(er, "error_codes")))
# } )
xml <- gnp(error_url$badVerb)
expect_error( handle_errors(xml) )
expect_true( tryCatch( handle_errors(xml), error=function(er) inherits(er, "oai-pmh_error") ) )
expect_true( tryCatch( handle_errors(xml), error=function(er) "badVerb" %in% attr(er, "error_codes")))
} )

# test_that("cannotDisseminateFormat is triggered", {
# skip_on_cran()
test_that("cannotDisseminateFormat is triggered", {
skip_on_cran()

# xml <- gnp(error_url$cannotDisseminateFormat)
# expect_error( handle_errors(xml) )
# expect_true( tryCatch( handle_errors(xml), error=function(er) inherits(er, "oai-pmh_error") ) )
# expect_true( tryCatch( handle_errors(xml), error=function(er) "cannotDisseminateFormat" %in% attr(er, "error_codes")))
# } )
xml <- gnp(error_url$cannotDisseminateFormat)
expect_error( handle_errors(xml) )
expect_true( tryCatch( handle_errors(xml), error=function(er) inherits(er, "oai-pmh_error") ) )
expect_true( tryCatch( handle_errors(xml), error=function(er) "cannotDisseminateFormat" %in% attr(er, "error_codes")))
} )

# test_that("idDoesNotExist is triggered", {
# skip_on_cran()
test_that("idDoesNotExist is triggered", {
skip_on_cran()

# xml <- gnp(error_url$idDoesNotExist)
# expect_error( handle_errors(xml) )
# expect_true( tryCatch( handle_errors(xml), error=function(er) inherits(er, "oai-pmh_error") ) )
# expect_true( tryCatch( handle_errors(xml), error=function(er) "idDoesNotExist" %in% attr(er, "error_codes")))
# } )
xml <- gnp(error_url$idDoesNotExist)
expect_error( handle_errors(xml) )
expect_true( tryCatch( handle_errors(xml), error=function(er) inherits(er, "oai-pmh_error") ) )
expect_true( tryCatch( handle_errors(xml), error=function(er) "idDoesNotExist" %in% attr(er, "error_codes")))
} )

# test_that("noRecordsMatch is triggered", {
# skip_on_cran()
test_that("noRecordsMatch is triggered", {
skip_on_cran()

# xml <- gnp(error_url$noRecordsMatch)
# expect_error( handle_errors(xml) )
# expect_true( tryCatch( handle_errors(xml), error=function(er) inherits(er, "oai-pmh_error") ) )
# expect_true( tryCatch( handle_errors(xml), error=function(er) "noRecordsMatch" %in% attr(er, "error_codes")))
# } )
xml <- gnp(error_url$noRecordsMatch)
expect_error( handle_errors(xml) )
expect_true( tryCatch( handle_errors(xml), error=function(er) inherits(er, "oai-pmh_error") ) )
expect_true( tryCatch( handle_errors(xml), error=function(er) "noRecordsMatch" %in% attr(er, "error_codes")))
} )


# test_that("noSetHierarchy is triggered", {
# skip_on_cran()
test_that("noSetHierarchy is triggered", {
skip_on_cran()

# if (!is.null(error_url$noSetHierarchy)) {
# xml <- gnp(error_url$noSetHierarchy)
# expect_error( handle_errors(xml) )
# expect_true( tryCatch( handle_errors(xml), error=function(er) inherits(er, "oai-pmh_error") ) )
# expect_true( tryCatch( handle_errors(xml), error=function(er) "noSetHierarchy" %in% attr(er, "error_codes")))
# }
if (!is.null(error_url$noSetHierarchy)) {
xml <- gnp(error_url$noSetHierarchy)
expect_error( handle_errors(xml) )
expect_true( tryCatch( handle_errors(xml), error=function(er) inherits(er, "oai-pmh_error") ) )
expect_true( tryCatch( handle_errors(xml), error=function(er) "noSetHierarchy" %in% attr(er, "error_codes")))
}

# })
})

# rm(tomorrow, error_url, gnp)
rm(tomorrow, error_url, gnp)

0 comments on commit 03f5096

Please sign in to comment.