Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removal of revision_list and package_revision_list in CKAN 2.9 #200

Merged
merged 2 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions R/package_revision_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,19 @@
package_revision_list <- function(id, url = get_default_url(),
key = get_default_key(), as = "list", ...) {

res <- ckan_GET(url, 'package_revision_list', list(id = id),
ver <- try(ckan_version(url)$version_num, silent = TRUE)
if (inherits(ver, "try-error")) {
ver <- NA
}

if (ver >= 29.0) {
warning('The ckan.logic.action.get.package_revision_list endpoint was removed in CKAN 2.9. Returning NULL.')
result <- NULL
} else {
res <- ckan_GET(url, 'package_revision_list', list(id = id),
key = key, opts = list(...))
switch(as, json = res, list = jsl(res), table = jsd(res))
result <- switch(as, json = res, list = jsl(res), table = jsd(res))
}

result
}
15 changes: 13 additions & 2 deletions R/revision_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
revision_list <- function(url = get_default_url(), key = get_default_key(),
as = "list", ...) {

res <- ckan_GET(url, 'revision_list', key = key, opts = list(...))
switch(as, json = res, list = jsl(res), table = jsd(res))
ver <- try(ckan_version(url)$version_num, silent = TRUE)
if (inherits(ver, "try-error")) {
ver <- NA
}

if (ver >= 29.0) {
warning('The ckan.logic.action.get.revision_list endpoint was removed in CKAN 2.9. Returning NULL.')
result <- NULL
} else {
res <- ckan_GET(url, 'revision_list', key = key, opts = list(...))
result <- switch(as, json = res, list = jsl(res), table = jsd(res))
}
result
}
40 changes: 25 additions & 15 deletions tests/testthat/test-package_revision_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,30 @@ context("package_revision_list")
skip_on_cran()

u <- get_test_url()
ver <- try(ckan_version(u)$version_num, silent = TRUE)

test_that("package_revision_list gives back expected class types", {
check_ckan(u)
.a <- package_list_current(limit=1, url=u)
a <- package_revision_list(.a[[1]]$id, url=u)
expect_is(a, "list")
})
if (ver >= 29.0) {
test_that("removal of package_revision_list endpoint", {
check_ckan(u)
a <- expect_warning(package_revision_list(url=u), "The ckan.logic.action.get.package_revision_list endpoint was removed in CKAN 2.9. Returning NULL.")
expect_null(a)
})
} else {
test_that("package_revision_list gives back expected class types", {
check_ckan(u)
.a <- package_list_current(limit=1, url=u)
a <- package_revision_list(.a[[1]]$id, url=u)
expect_is(a, "list")
})

test_that("package_revision_list works giving back json output", {
check_ckan(u)
.b <- package_list_current(limit=1, url=u)
b <- package_revision_list(.b[[1]]$id, url=u, as="json")
b_df <- jsonlite::fromJSON(b)
expect_is(b, "character")
expect_is(b_df, "list")
expect_is(b_df$result, "data.frame")
})
}

test_that("package_revision_list works giving back json output", {
check_ckan(u)
.b <- package_list_current(limit=1, url=u)
b <- package_revision_list(.b[[1]]$id, url=u, as="json")
b_df <- jsonlite::fromJSON(b)
expect_is(b, "character")
expect_is(b_df, "list")
expect_is(b_df$result, "data.frame")
})
34 changes: 22 additions & 12 deletions tests/testthat/test-revision_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,27 @@ context("revision_list")
skip_on_cran()

u <- get_test_url()
ver <- try(ckan_version(u)$version_num, silent = TRUE)

test_that("revision_list gives back expected class types", {
check_ckan(u)
a <- revision_list(url=u)
expect_is(a, "list")
})
if(ver >= 29.0) {
test_that("removal of revision_list endpoint", {
check_ckan(u)
a <- expect_warning(revision_list(url=u), "The ckan.logic.action.get.revision_list endpoint was removed in CKAN 2.9. Returning NULL.")
expect_null(a)
})
} else {
test_that("revision_list gives back expected class types", {
check_ckan(u)
a <- revision_list(url=u)
expect_is(a, "list")
})

test_that("revision_list works giving back json output", {
check_ckan(u)
b <- revision_list(url=u, as="json")
expect_is(b, "character")
b_df <- jsonlite::fromJSON(b)
expect_is(b_df, "list")
})
}

test_that("revision_list works giving back json output", {
check_ckan(u)
b <- revision_list(url=u, as="json")
expect_is(b, "character")
b_df <- jsonlite::fromJSON(b)
expect_is(b_df, "list")
})