Skip to content

Commit

Permalink
update tests for #92
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Dec 5, 2023
1 parent 902d68d commit 0420d7b
Show file tree
Hide file tree
Showing 40 changed files with 847 additions and 1,568 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: deposits
Title: A universal client for depositing and accessing research data
anywhere
Version: 0.2.1.049
Version: 0.2.1.050
Authors@R:
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265"))
Expand Down
2 changes: 0 additions & 2 deletions R/httptest2-mocks.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ httptest2_hostdata_timestamps <- function (hostdata, service) {

} else if (service == "zenodo") {

hostdata$created <- mockdate

if ("modified" %in% names (hostdata)) {
hostdata$modified <- mockdate
}
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"codeRepository": "https://github.com/ropenscilabs/deposits",
"issueTracker": "https://github.com/ropenscilabs/deposits/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "0.2.1.049",
"version": "0.2.1.050",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down
32 changes: 14 additions & 18 deletions tests/testthat/test-client-zenodo.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ test_that ("zenodo embargo", {
cli <- new_mock_deposit (service = service)
deposit_id <- cli$id

expect_equal (cli$hostdata$metadata$access_right, "closed")
expect_equal (cli$hostdata$metadata$access_right, "restricted")

expect_error (
cli$deposit_embargo (embargo_date = 1),
Expand Down Expand Up @@ -448,24 +448,18 @@ test_that ("zenodo version", {

service <- "zenodo"

cli <- with_mock_dir ("zen_create", {
depositsClient$new (service = service, sandbox = TRUE)
})

cli <- with_mock_dir ("zen_get_publ", {
cli$deposit_retrieve (cli$deposits$id [1])
})
cli <- new_mock_deposit (service = service)

# Increment version number:
vers0 <- cli$hostdata$metadata$version
vers <- regmatches (vers0, regexpr ("[0-9]*$", vers0))
vers <- regmatches (vers0, regexpr ("[0-9].*$", vers0))
nc <- nchar (vers)
vers <- sprintf (paste0 ("%0", nc, "i"), as.integer (vers) + 1L)
vers <- gsub ("[0-9]*$", vers, vers0)
incr <- as.integer (substring (vers, nc, nc)) + 1L
substring (vers, nc, nc) <- paste0 (incr)

cre <- lapply (
cli$hostdata$metadata$creators$name,
function (i) list (name = i)
cli$hostdata$metadata$creators,
function (i) list (name = i$name)
)
metadata <- list (
title = cli$hostdata$metadata$title,
Expand All @@ -476,12 +470,14 @@ test_that ("zenodo version", {
)
cli$deposit_fill_metadata (metadata)

cli <- with_mock_dir ("zen_vers", {
cli$deposit_version ()
})
# This can no longer be tested, because deposit data are no longer returned
# from, or listed on, sandbox:
# cli <- with_mock_dir ("zen_vers", {
# cli$deposit_version ()
# })

expect_equal (cli$hostdata$metadata$version, vers)
expect_false (cli$hostdata$metadata$version == vers0)
# expect_equal (cli$hostdata$metadata$version, vers)
# expect_false (cli$hostdata$metadata$version == vers0)
})

# can't mock delete because it returns an empty body
Expand Down
146 changes: 1 addition & 145 deletions tests/testthat/zen_client/sbapi/deposit/depositions-fa7f86.json
Original file line number Diff line number Diff line change
@@ -1,147 +1,3 @@
[
{
"conceptdoi": "10.5072/zenodo.1206119",
"conceptrecid": "1206119",
"created": "2022-01-01T00:00:00",
"doi": "10.5072/zenodo.1206120",
"doi_url": "https://doi.org/10.5072/zenodo.1206120",
"files": [
{
"checksum": "762fc94bc138735cd70afc714a2db7b0",
"filename": "typetracer_0.1.1.006.tar.gz",
"filesize": 24499,
"id": "568d0149-29d0-4dcc-85eb-0cab65333cfc",
"links": {
"download": "sbapi/files/hash/typetracer_0.1.1.006.tar.gz",
"self": "sbapi/deposit/depositions/1206120/files/568d0149-29d0-4dcc-85eb-0cab65333cfc"
}
}
],
"id": 1206120,
"links": {
"badge": "https://sandbox.zenodo.org/badge/doi/10.5072/zenodo.1206120.svg",
"bucket": "sbapi/files/4321a0d3-3414-4b55-bbbc-81e0f95f1bfd",
"conceptbadge": "https://sandbox.zenodo.org/badge/doi/10.5072/zenodo.1206119.svg",
"conceptdoi": "https://doi.org/10.5072/zenodo.1206119",
"discard": "sbapi/deposit/depositions/1206120/actions/discard",
"doi": "https://doi.org/10.5072/zenodo.1206120",
"edit": "sbapi/deposit/depositions/1206120/actions/edit",
"files": "sbapi/deposit/depositions/1206120/files",
"html": "https://sandbox.zenodo.org/deposit/1206120",
"latest": "sbapi/records/1206120",
"latest_html": "https://sandbox.zenodo.org/record/1206120",
"publish": "sbapi/deposit/depositions/1206120/actions/publish",
"record": "sbapi/records/1206120",
"record_html": "https://sandbox.zenodo.org/record/1206120",
"self": "sbapi/deposit/depositions/1206120"
},
"metadata": {
"access_right": "closed",
"creators": [
{
"name": "Mark Padgham",
"orcid": "0000-0003-2172-5265"
}
],
"description": "<p>The &#39;R&#39; language includes a set of defined types, but the language itself is &quot;absurdly dynamic&quot; (Turcotte &amp; Vitek (2019)\\n), and lacks any way to specify which types are expected by any expression. The &#39;typetracer&#39; package enables code to be traced to extract detailed information on the properties of parameters\\npassed to &#39;R&#39; functions. &#39;typetracer&#39; can trace individual functions or\\nentire packages.<\/p>",
"doi": "10.5072/zenodo.1206120",
"prereserve_doi": {
"doi": "10.5072/zenodo.1206120",
"recid": 1206120
},
"publication_date": "2022-01-01",
"title": "Trace Function Parameter Types",
"upload_type": "software",
"version": "0.1.1.006"
},
"modified": "2022-01-01T00:00:00",
"owner": 115518,
"record_id": 1206120,
"state": "done",
"submitted": true,
"title": "Trace Function Parameter Types"
},
{
"conceptdoi": "10.5072/zenodo.1077311",
"conceptrecid": "1077311",
"created": "2022-01-01T00:00:00",
"doi": "10.5072/zenodo.1077312",
"doi_url": "https://doi.org/10.5072/zenodo.1077312",
"files": [
{
"checksum": "3b6fd6ea9689be256621fb7fcc3cd81f",
"filename": "DCEntry-1077312.xml",
"filesize": 829,
"id": "2b44d9ce-bf3f-45b1-8c59-dd24bcda6018",
"links": {
"download": "sbapi/files/hash/DCEntry-1077312.xml",
"self": "sbapi/deposit/depositions/1077312/files/2b44d9ce-bf3f-45b1-8c59-dd24bcda6018"
}
},
{
"checksum": "2f66f32c95d5ff3ccd3ddd1cadc797b0",
"filename": "RJwrapper.pdf",
"filesize": 36414,
"id": "cdc0fa50-4582-4830-a6b7-63999ce736c4",
"links": {
"download": "sbapi/files/hash/RJwrapper.pdf",
"self": "sbapi/deposit/depositions/1077312/files/cdc0fa50-4582-4830-a6b7-63999ce736c4"
}
}
],
"id": 1077312,
"links": {
"badge": "https://sandbox.zenodo.org/badge/doi/10.5072/zenodo.1077312.svg",
"bucket": "sbapi/files/57f59a19-a514-4e97-9273-85a65bdd267e",
"conceptbadge": "https://sandbox.zenodo.org/badge/doi/10.5072/zenodo.1077311.svg",
"conceptdoi": "https://doi.org/10.5072/zenodo.1077311",
"discard": "sbapi/deposit/depositions/1077312/actions/discard",
"doi": "https://doi.org/10.5072/zenodo.1077312",
"edit": "sbapi/deposit/depositions/1077312/actions/edit",
"files": "sbapi/deposit/depositions/1077312/files",
"html": "https://sandbox.zenodo.org/deposit/1077312",
"latest": "sbapi/records/1077312",
"latest_html": "https://sandbox.zenodo.org/record/1077312",
"publish": "sbapi/deposit/depositions/1077312/actions/publish",
"record": "sbapi/records/1077312",
"record_html": "https://sandbox.zenodo.org/record/1077312",
"self": "sbapi/deposit/depositions/1077312"
},
"metadata": {
"access_right": "closed",
"communities": [
{
"identifier": "zenodo"
}
],
"creators": [
{
"name": "P.S. Reynolds"
}
],
"description": "Updated source of 'beaver' data, in Chapter 11 of Lange, N., Ryan, L., Billard, L., Brillinger, D., Conquest, L. and Greenhouse, J. eds (1994) Case Studies in Biometry.",
"doi": "10.5072/zenodo.1077312",
"journal_title": "John Wiley and Sons",
"prereserve_doi": {
"doi": "10.5072/zenodo.1077312",
"recid": 1077312
},
"publication_date": "2022-01-01",
"related_identifiers": [
{
"identifier": "ark:/13960/t0mt2n370",
"relation": "isPartOf",
"scheme": "ark"
}
],
"title": "Updated time-series analyses of beaver body temperatures.",
"upload_type": "other"
},
"modified": "2022-01-01T00:00:00",
"owner": 115518,
"record_id": 1077312,
"state": "inprogress",
"submitted": true,
"title": "Updated time-series analyses of beaver body temperatures."
}

]
146 changes: 1 addition & 145 deletions tests/testthat/zen_create/sbapi/deposit/depositions-fa7f86.json
Original file line number Diff line number Diff line change
@@ -1,147 +1,3 @@
[
{
"conceptdoi": "10.5072/zenodo.1206119",
"conceptrecid": "1206119",
"created": "2022-01-01T00:00:00",
"doi": "10.5072/zenodo.1206120",
"doi_url": "https://doi.org/10.5072/zenodo.1206120",
"files": [
{
"checksum": "762fc94bc138735cd70afc714a2db7b0",
"filename": "typetracer_0.1.1.006.tar.gz",
"filesize": 24499,
"id": "568d0149-29d0-4dcc-85eb-0cab65333cfc",
"links": {
"download": "sbapi/files/hash/typetracer_0.1.1.006.tar.gz",
"self": "sbapi/deposit/depositions/1206120/files/568d0149-29d0-4dcc-85eb-0cab65333cfc"
}
}
],
"id": 1206120,
"links": {
"badge": "https://sandbox.zenodo.org/badge/doi/10.5072/zenodo.1206120.svg",
"bucket": "sbapi/files/4321a0d3-3414-4b55-bbbc-81e0f95f1bfd",
"conceptbadge": "https://sandbox.zenodo.org/badge/doi/10.5072/zenodo.1206119.svg",
"conceptdoi": "https://doi.org/10.5072/zenodo.1206119",
"discard": "sbapi/deposit/depositions/1206120/actions/discard",
"doi": "https://doi.org/10.5072/zenodo.1206120",
"edit": "sbapi/deposit/depositions/1206120/actions/edit",
"files": "sbapi/deposit/depositions/1206120/files",
"html": "https://sandbox.zenodo.org/deposit/1206120",
"latest": "sbapi/records/1206120",
"latest_html": "https://sandbox.zenodo.org/record/1206120",
"publish": "sbapi/deposit/depositions/1206120/actions/publish",
"record": "sbapi/records/1206120",
"record_html": "https://sandbox.zenodo.org/record/1206120",
"self": "sbapi/deposit/depositions/1206120"
},
"metadata": {
"access_right": "closed",
"creators": [
{
"name": "Mark Padgham",
"orcid": "0000-0003-2172-5265"
}
],
"description": "<p>The &#39;R&#39; language includes a set of defined types, but the language itself is &quot;absurdly dynamic&quot; (Turcotte &amp; Vitek (2019)\\n), and lacks any way to specify which types are expected by any expression. The &#39;typetracer&#39; package enables code to be traced to extract detailed information on the properties of parameters\\npassed to &#39;R&#39; functions. &#39;typetracer&#39; can trace individual functions or\\nentire packages.<\/p>",
"doi": "10.5072/zenodo.1206120",
"prereserve_doi": {
"doi": "10.5072/zenodo.1206120",
"recid": 1206120
},
"publication_date": "2022-01-01",
"title": "Trace Function Parameter Types",
"upload_type": "software",
"version": "0.1.1.006"
},
"modified": "2022-01-01T00:00:00",
"owner": 115518,
"record_id": 1206120,
"state": "done",
"submitted": true,
"title": "Trace Function Parameter Types"
},
{
"conceptdoi": "10.5072/zenodo.1077311",
"conceptrecid": "1077311",
"created": "2022-01-01T00:00:00",
"doi": "10.5072/zenodo.1077312",
"doi_url": "https://doi.org/10.5072/zenodo.1077312",
"files": [
{
"checksum": "3b6fd6ea9689be256621fb7fcc3cd81f",
"filename": "DCEntry-1077312.xml",
"filesize": 829,
"id": "2b44d9ce-bf3f-45b1-8c59-dd24bcda6018",
"links": {
"download": "sbapi/files/hash/DCEntry-1077312.xml",
"self": "sbapi/deposit/depositions/1077312/files/2b44d9ce-bf3f-45b1-8c59-dd24bcda6018"
}
},
{
"checksum": "2f66f32c95d5ff3ccd3ddd1cadc797b0",
"filename": "RJwrapper.pdf",
"filesize": 36414,
"id": "cdc0fa50-4582-4830-a6b7-63999ce736c4",
"links": {
"download": "sbapi/files/hash/RJwrapper.pdf",
"self": "sbapi/deposit/depositions/1077312/files/cdc0fa50-4582-4830-a6b7-63999ce736c4"
}
}
],
"id": 1077312,
"links": {
"badge": "https://sandbox.zenodo.org/badge/doi/10.5072/zenodo.1077312.svg",
"bucket": "sbapi/files/57f59a19-a514-4e97-9273-85a65bdd267e",
"conceptbadge": "https://sandbox.zenodo.org/badge/doi/10.5072/zenodo.1077311.svg",
"conceptdoi": "https://doi.org/10.5072/zenodo.1077311",
"discard": "sbapi/deposit/depositions/1077312/actions/discard",
"doi": "https://doi.org/10.5072/zenodo.1077312",
"edit": "sbapi/deposit/depositions/1077312/actions/edit",
"files": "sbapi/deposit/depositions/1077312/files",
"html": "https://sandbox.zenodo.org/deposit/1077312",
"latest": "sbapi/records/1077312",
"latest_html": "https://sandbox.zenodo.org/record/1077312",
"publish": "sbapi/deposit/depositions/1077312/actions/publish",
"record": "sbapi/records/1077312",
"record_html": "https://sandbox.zenodo.org/record/1077312",
"self": "sbapi/deposit/depositions/1077312"
},
"metadata": {
"access_right": "closed",
"communities": [
{
"identifier": "zenodo"
}
],
"creators": [
{
"name": "P.S. Reynolds"
}
],
"description": "Updated source of 'beaver' data, in Chapter 11 of Lange, N., Ryan, L., Billard, L., Brillinger, D., Conquest, L. and Greenhouse, J. eds (1994) Case Studies in Biometry.",
"doi": "10.5072/zenodo.1077312",
"journal_title": "John Wiley and Sons",
"prereserve_doi": {
"doi": "10.5072/zenodo.1077312",
"recid": 1077312
},
"publication_date": "2022-01-01",
"related_identifiers": [
{
"identifier": "ark:/13960/t0mt2n370",
"relation": "isPartOf",
"scheme": "ark"
}
],
"title": "Updated time-series analyses of beaver body temperatures.",
"upload_type": "other"
},
"modified": "2022-01-01T00:00:00",
"owner": 115518,
"record_id": 1077312,
"state": "inprogress",
"submitted": true,
"title": "Updated time-series analyses of beaver body temperatures."
}

]
Loading

0 comments on commit 0420d7b

Please sign in to comment.