tests/testthat/test-id.R

context("id")

test_that("id - default uses datacite", {
  skip_on_cran()

  aa <- id("http://oai.datacite.org/oai")

  expect_is(aa, "data.frame")
  expect_match(aa$repositoryName, "DataCite")
  expect_match(aa$baseURL, "oai.datacite.org")
})

test_that("id - url param works", {
  skip_on_cran()

  aa <- id("http://export.arxiv.org/oai2")
  #bb <- id("http://pub.bsalut.net/cgi/oai2.cgi")
  cc <- id("http://www.diva-portal.org/oai/OAI")

  expect_is(aa, "data.frame")
  #expect_is(bb, "data.frame")
  expect_is(cc, "data.frame")

  expect_equal(NROW(aa), 1)
  #expect_equal(NROW(bb), 1)
  expect_equal(NROW(cc), 1)
})

test_that("id - as param works", {
  skip_on_cran()

  expect_error(id("http://oai.datacite.org/oai", as = "stuff"), 
    "'as' must be one of")

  aa <- id("http://oai.datacite.org/oai", as = "raw")
  bb <- id("http://oai.datacite.org/oai", as = "parsed")

  expect_is(aa, "character")
  expect_is(bb, "data.frame")
})

test_that("id fails well", {
  skip_on_cran()

  expect_error(id(),
               "argument \"url\" is missing")
  expect_error(id("things"),
               "One or more of your URLs")
})

Try the oai package in your browser

Any scripts or data that you put into this service are public.

oai documentation built on Nov. 10, 2022, 5:54 p.m.