├── .Rbuildignore ├── .github ├── .gitignore └── workflows │ ├── R-CMD-check.yaml │ └── test-coverage.yaml ├── .gitignore ├── .hooks └── description ├── .pre-commit-config.yaml ├── DESCRIPTION ├── LICENSE ├── Makefile ├── NAMESPACE ├── R ├── ISO-639-2-language-codes.R ├── client-main.R ├── client-private-dcmi2host.R ├── client-private-embargo-publish.R ├── client-private-frictionless.R ├── client-private-methods.R ├── deposits-package.R ├── desc-to-meta.R ├── figshare-categories.R ├── httptest2-mocks.R ├── httr2-helpers.R ├── metadata-dcmi.R ├── metadata-template.R ├── metadata-translate.R ├── metadata-validate.R ├── search-params.R ├── service-desc-meta.R ├── service-functions.R ├── service-methods.R ├── service-urls.R ├── tokens.R ├── upload-figshare.R ├── upload-zenodo.R └── utils.R ├── README.Rmd ├── README.md ├── _pkgdown.yml ├── codemeta.json ├── data-raw ├── get-dcmi-xml.R └── get-zenodo-licenses.R ├── inst ├── extdata │ ├── dc │ │ ├── dc.xsd │ │ ├── dcmitype.xsd │ │ ├── dcterms.xsd │ │ ├── schema-template.json │ │ └── schema.json │ ├── figshare │ │ ├── from_dc.json │ │ └── schema.json │ └── zenodo │ │ ├── from_dc.json │ │ ├── schema.json │ │ ├── to_dc.json │ │ └── zenodo_licenses.csv └── httptest2 │ └── redact.R ├── man ├── dcmi_terms.Rd ├── deposits-package.Rd ├── depositsClient.Rd ├── deposits_metadata_template.Rd ├── deposits_services.Rd ├── figshare_categories.Rd └── get_deposits_token.Rd ├── tests ├── script.bash ├── testthat.R └── testthat │ ├── _snaps │ └── client.md │ ├── client-new │ └── api │ │ └── account │ │ └── articles.json │ ├── fs_client │ └── api │ │ └── account │ │ └── articles.json │ ├── fs_create │ └── api │ │ └── account │ │ └── articles.json │ ├── fs_get_publ │ └── api │ │ ├── account │ │ └── articles.json │ │ └── articles │ │ └── 23514972.json │ ├── fs_list │ └── api │ │ └── account │ │ └── articles.json │ ├── fs_new │ └── api │ │ ├── account │ │ ├── articles-8417b4-POST.R │ │ └── articles.json │ │ └── articles │ │ └── 23522487.json │ ├── fs_new2 │ └── api │ │ ├── account │ │ ├── articles-8417b4-POST.R │ │ └── articles.json │ │ └── articles │ │ └── 23522484.json │ ├── fs_retr │ └── api │ │ ├── account │ │ └── articles.json │ │ └── articles │ │ └── 23522487.json │ ├── fs_up │ ├── api │ │ ├── account │ │ │ └── articles.json │ │ └── articles │ │ │ ├── 23522487 │ │ │ ├── files-8d2582-POST.R │ │ │ └── files │ │ │ │ ├── 41251068-POST.R │ │ │ │ └── 41251068.json │ │ │ ├── 23522487-54b0b5-PUT.R │ │ │ └── 23522487.json │ ├── files │ │ └── hash │ │ │ └── 1-861b94-PUT.txt │ └── fup-eu-west-1.up │ │ └── 04b4b28d-1bb0-454b-a8f6-537a7462ad28.json │ ├── fs_up2 │ ├── api │ │ ├── account │ │ │ └── articles.json │ │ └── articles │ │ │ ├── 23522487 │ │ │ ├── files-e3c461-POST.R │ │ │ └── files │ │ │ │ ├── 41251092-POST.R │ │ │ │ └── 41251092.json │ │ │ ├── 23522487-54b0b5-PUT.R │ │ │ └── 23522487.json │ ├── files │ │ └── hash │ │ │ └── 1-861b94-PUT.txt │ └── fup-eu-west-1.up │ │ └── aa8d38ef-a31c-4852-b3f8-ecdebec4f6df.json │ ├── fs_update │ └── api │ │ ├── account │ │ └── articles.json │ │ └── articles │ │ ├── 23522487-c14ad9-PUT.R │ │ └── 23522487.json │ ├── fs_update_dp1 │ └── api │ │ └── articles │ │ └── 23522487-54b0b5-PUT.R │ ├── fs_update_dp2 │ └── api │ │ └── articles │ │ └── 23522487-1e2e5c-PUT.R │ ├── helper-test-client.R │ ├── meta-new1 │ └── sbapi │ │ └── deposit │ │ └── depositions-fa7f86.json │ ├── meta-new2 │ └── sbapi │ │ └── deposit │ │ └── depositions-fa7f86.json │ ├── meta-new3 │ └── sbapi │ │ └── deposit │ │ └── depositions-fa7f86.json │ ├── meta-new4 │ └── sbapi │ │ └── deposit │ │ └── depositions-fa7f86.json │ ├── print-fs │ └── api │ │ └── account │ │ └── articles.json │ ├── print-zen │ └── sbapi │ │ └── deposit │ │ └── depositions-fa7f86.json │ ├── search_fs │ └── api │ │ └── articles │ │ └── search-b2e6ce-POST.json │ ├── search_zen │ └── sbapi │ │ └── records-53e6de.json │ ├── services_fs │ └── api │ │ └── account │ │ └── articles.json │ ├── services_zen │ └── sbapi │ │ └── deposit │ │ └── depositions-fa7f86.json │ ├── test-client-figshare.R │ ├── test-client-metadata.R │ ├── test-client-zenodo.R │ ├── test-client.R │ ├── test-figshare-categories.R │ ├── test-iso-639-languages.R │ ├── test-metadata-validate.R │ ├── test-search.R │ ├── test-services.R │ ├── zen_client │ └── sbapi │ │ └── deposit │ │ └── depositions-fa7f86.json │ ├── zen_create │ └── sbapi │ │ └── deposit │ │ └── depositions-fa7f86.json │ ├── zen_dl │ └── sbapi │ │ ├── deposit │ │ └── depositions │ │ │ └── 29712.json │ │ └── records │ │ └── 29712 │ │ └── draft │ │ └── files │ │ └── data.csv │ │ └── content.txt │ ├── zen_dl_fail │ └── sbapi │ │ └── deposit │ │ └── depositions │ │ └── 29712.json │ ├── zen_embargo │ └── sbapi │ │ └── deposit │ │ └── depositions │ │ └── 29712-8f7fb0-PUT.json │ ├── zen_list │ └── sbapi │ │ └── deposit │ │ └── depositions-fa7f86.json │ ├── zen_new │ └── sbapi │ │ └── deposit │ │ ├── depositions-c69359-POST.R │ │ └── depositions-fa7f86.json │ ├── zen_retr │ └── sbapi │ │ └── deposit │ │ └── depositions │ │ └── 29712.json │ ├── zen_up │ └── sbapi │ │ ├── deposit │ │ └── depositions │ │ │ ├── 29712-6ea865-PUT.json │ │ │ └── 29712.json │ │ └── files │ │ └── hash │ │ └── data.csv-861b94-PUT.R │ ├── zen_up2 │ └── sbapi │ │ ├── deposit │ │ └── depositions │ │ │ ├── 29712-6ea865-PUT.json │ │ │ └── 29712.json │ │ └── files │ │ └── hash │ │ └── data2.csv-861b94-PUT.R │ ├── zen_update │ └── sbapi │ │ └── deposit │ │ └── depositions │ │ ├── 29712-455baf-PUT.json │ │ └── 29712.json │ └── zen_update_dp │ └── sbapi │ └── deposit │ └── depositions │ └── 29712-342c38-PUT.json └── vignettes ├── deposits-R6.Rmd ├── deposits.Rmd ├── fig1.png ├── fig1.tex ├── frictionless.Rmd ├── install-setup.Rmd ├── makefile ├── metadata.Rmd ├── versioning.Rmd └── workflow.Rmd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^CODE_OF_CONDUCT\.md$ 3 | ^CONTRIBUTING.md$ 4 | ^Dockerfile$ 5 | ^README\.Rmd$ 6 | ^README\.md$ 7 | ^\.Rproj\.user$ 8 | ^\.github$ 9 | ^\.hooks$ 10 | ^\.pre-commit-config\.yaml$ 11 | ^_pkgdown\.yml$ 12 | ^aaa.Rmd$ 13 | ^appveyor\.yml$ 14 | ^codemeta\.json$ 15 | ^ctags$ 16 | ^docs$ 17 | ^inst/WORDLIST$ 18 | ^inst/precommit$ 19 | ^makefile$ 20 | ^pkgdown$ 21 | ^vignettes/makefile$ 22 | data-raw/ 23 | vignettes/*.tex$ 24 | .ropensci-staff 25 | -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | 9 | name: R-CMD-check 10 | 11 | jobs: 12 | R-CMD-check: 13 | runs-on: ${{ matrix.config.os }} 14 | 15 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 16 | 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | config: 21 | - {os: macos-latest, r: 'release'} 22 | - {os: windows-latest, r: 'release'} 23 | - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} 24 | - {os: ubuntu-latest, r: 'release'} 25 | - {os: ubuntu-latest, r: 'oldrel-1'} 26 | 27 | env: 28 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 29 | R_KEEP_PKG_SOURCE: yes 30 | FIGSHARE_TOKEN: ${{ secrets.FIGSHARE_TOKEN }} 31 | ZENODO_TOKEN: ${{ secrets.ZENODO_TOKEN }} 32 | ZENODO_SANDBOX_TOKEN: ${{ secrets.ZENODO_SANDBOX_TOKEN }} 33 | 34 | 35 | 36 | steps: 37 | - uses: actions/checkout@v3 38 | 39 | - uses: r-lib/actions/setup-pandoc@v2 40 | 41 | - uses: r-lib/actions/setup-r@v2 42 | with: 43 | r-version: ${{ matrix.config.r }} 44 | http-user-agent: ${{ matrix.config.http-user-agent }} 45 | use-public-rspm: true 46 | 47 | - uses: r-lib/actions/setup-r-dependencies@v2 48 | with: 49 | extra-packages: any::rcmdcheck 50 | needs: check 51 | 52 | - uses: r-lib/actions/check-r-package@v2 53 | with: 54 | upload-snapshots: true 55 | -------------------------------------------------------------------------------- /.github/workflows/test-coverage.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | 9 | name: test-coverage 10 | 11 | jobs: 12 | test-coverage: 13 | runs-on: ubuntu-latest 14 | env: 15 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 16 | FIGSHARE_TOKEN: ${{ secrets.FIGSHARE_TOKEN }} 17 | ZENODO_TOKEN: ${{ secrets.ZENODO_TOKEN }} 18 | ZENODO_SANDBOX_TOKEN: ${{ secrets.ZENODO_SANDBOX_TOKEN }} 19 | 20 | steps: 21 | - uses: actions/checkout@v3 22 | 23 | - uses: r-lib/actions/setup-r@v2 24 | with: 25 | use-public-rspm: true 26 | 27 | - uses: r-lib/actions/setup-r-dependencies@v2 28 | with: 29 | extra-packages: any::covr 30 | needs: coverage 31 | 32 | - name: Test coverage 33 | run: | 34 | covr::codecov( 35 | quiet = FALSE, 36 | clean = FALSE, 37 | install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package") 38 | ) 39 | shell: Rscript {0} 40 | 41 | - name: Show testthat output 42 | if: always() 43 | run: | 44 | ## -------------------------------------------------------------------- 45 | find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true 46 | shell: bash 47 | 48 | - name: Upload test results 49 | if: failure() 50 | uses: actions/upload-artifact@v3 51 | with: 52 | name: coverage-test-failures 53 | path: ${{ runner.temp }}/package 54 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | inst/doc 5 | inst/WORDLIST 6 | aaa\.Rmd* 7 | # History files 8 | .Rhistory 9 | .Rapp.history 10 | # Session Data files 11 | .RData 12 | # Output files from R CMD build 13 | /*.tar.gz 14 | # vim files 15 | .*.un~ 16 | .*.swp 17 | # compiled object files 18 | *.o 19 | *.so 20 | docs 21 | -------------------------------------------------------------------------------- /.hooks/description: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env Rscript 2 | 3 | # only stop on main branch 4 | on_main <- identical (gert::git_branch (), "main") 5 | 6 | s <- gert::git_status() 7 | chk <- ("DESCRIPTION" %in% s$file && 8 | (s$status [s$file == "DESCRIPTION"] == "modified" | 9 | s$status [s$file == "DESCRIPTION"] == "new")) 10 | if (!chk & on_main) 11 | stop ("DESCRIPTION has not been updated") 12 | 13 | f <- file.path (rprojroot::find_root("DESCRIPTION"), "DESCRIPTION") 14 | x <- system2 ("git", args = c ("diff", "--cached", "-U0", f), stdout = TRUE) 15 | if (!any (grepl ("^\\+Version", x)) & on_main) 16 | stop ("Version number in DESCRIPTION has not been incremented") 17 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # All available hooks: https://pre-commit.com/hooks.html 2 | # R specific hooks: https://github.com/lorenzwalthert/precommit 3 | repos: 4 | - repo: https://github.com/lorenzwalthert/precommit 5 | rev: v0.4.3 6 | hooks: 7 | - id: style-files 8 | args: [--style_pkg=spaceout, --style_fun=spaceout_style] 9 | additional_dependencies: 10 | - ropensci-review-tools/spaceout 11 | # - id: roxygenize 12 | # codemeta must be above use-tidy-description when both are used 13 | # - id: codemeta-description-updated 14 | - id: use-tidy-description 15 | - id: spell-check 16 | exclude: > 17 | (?x)^( 18 | .*\.[rR]| 19 | .*\.feather| 20 | .*\.jpeg| 21 | .*\.pdf| 22 | .*\.png| 23 | .*\.py| 24 | .*\.RData| 25 | .*\.rds| 26 | .*\.Rds| 27 | .*\.Rproj| 28 | .*\.sh| 29 | (.*/|)\.gitignore| 30 | (.*/|)\.gitlab-ci\.yml| 31 | (.*/|)\.lintr| 32 | (.*/|)\.pre-commit-.*| 33 | (.*/|)\.Rbuildignore| 34 | (.*/|)\.Renviron| 35 | (.*/|)\.Rprofile| 36 | (.*/|)\.travis\.yml| 37 | (.*/|)appveyor\.yml| 38 | (.*/|)NAMESPACE| 39 | (.*/|)renv/settings\.dcf| 40 | (.*/|)renv\.lock| 41 | (.*/|)WORDLIST| 42 | \.github/workflows/.*| 43 | data/.*| 44 | )$ 45 | # - id: lintr 46 | - id: readme-rmd-rendered 47 | - id: parsable-R 48 | - id: no-browser-statement 49 | - id: no-print-statement 50 | - id: no-debug-statement 51 | - id: deps-in-desc 52 | # - id: pkgdown 53 | - repo: https://github.com/pre-commit/pre-commit-hooks 54 | rev: v4.6.0 55 | hooks: 56 | - id: check-added-large-files 57 | args: ['--maxkb=200'] 58 | - id: file-contents-sorter 59 | files: '^\.Rbuildignore$' 60 | - id: end-of-file-fixer 61 | exclude: '\.Rd' 62 | - repo: https://github.com/pre-commit-ci/pre-commit-ci-config 63 | rev: v1.6.1 64 | hooks: 65 | # Only required when https://pre-commit.ci is used for config validation 66 | - id: check-pre-commit-ci-config 67 | - repo: local 68 | hooks: 69 | - id: forbid-to-commit 70 | name: Don't commit common R artifacts 71 | entry: Cannot commit .Rhistory, .RData, .Rds or .rds. 72 | language: fail 73 | files: '\.(Rhistory|RData|Rds|rds)$' 74 | # `exclude: ` to allow committing specific files 75 | - id: description version 76 | name: Version has been incremeneted in DESCRIPTION 77 | entry: .hooks/description 78 | language: script 79 | 80 | ci: 81 | autoupdate_schedule: monthly 82 | # skip: [pkgdown] 83 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: deposits 2 | Title: A universal client for depositing and accessing research data 3 | anywhere 4 | Version: 0.2.1.061 5 | Authors@R: 6 | person("Mark", "Padgham", , "mark.padgham@email.com", role = c("aut", "cre"), 7 | comment = c(ORCID = "0000-0003-2172-5265")) 8 | Description: A universal client for depositing and accessing research data 9 | anywhere. Currently supported services are zenodo and figshare. 10 | License: MIT + file LICENSE 11 | URL: https://docs.ropensci.org/deposits/ 12 | BugReports: https://github.com/ropenscilabs/deposits/issues 13 | Imports: 14 | checkmate, 15 | fs, 16 | here, 17 | httr2, 18 | jsonlite, 19 | jsonvalidate, 20 | methods, 21 | R6, 22 | withr, 23 | xml2 24 | Suggests: 25 | frictionless, 26 | httptest2, 27 | knitr, 28 | pkgbuild, 29 | rmarkdown, 30 | testthat (>= 3.0.0) 31 | Config/testthat/edition: 3 32 | VignetteBuilder: 33 | knitr 34 | Encoding: UTF-8 35 | Roxygen: list(markdown = TRUE) 36 | RoxygenNote: 7.3.2 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2021 2 | COPYRIGHT HOLDER: deposits authors 3 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | VIGNETTE=deposits 2 | README=README 3 | 4 | .PHONY: all build check doc test 5 | 6 | all: docall build check 7 | 8 | build: docall 9 | R CMD build . 10 | 11 | #check: build 12 | # R CMD check typetracer*tar.gz 13 | 14 | clean: 15 | -rm -f deposits*tar.gz 16 | -rm -fr deposits.Rcheck 17 | -rm -fr src/*.{o,so} 18 | 19 | doc: 20 | Rscript -e 'devtools::document()' 21 | 22 | readme: 23 | Rscript -e 'rmarkdown::render("$(README).Rmd")' 24 | 25 | site: clean doc readme 26 | Rscript -e "pkgdown::build_home(quiet=FALSE)" 27 | Rscript -e "pkgdown::build_articles(quiet=FALSE)" 28 | Rscript -e "pkgdown::build_reference()" 29 | 30 | articles: 31 | Rscript -e "pkgdown::build_articles(quiet=FALSE)" 32 | 33 | docall: readme doc site 34 | 35 | open: 36 | xdg-open docs/index.html & 37 | 38 | test: 39 | Rscript -e 'devtools::test()' 40 | 41 | check: 42 | Rscript -e 'library(pkgcheck); checks <- pkgcheck(); print(checks); summary (checks)' 43 | 44 | knitr: $(README).Rmd 45 | echo "rmarkdown::render('$(README).Rmd',output_file='$(README).md')" | R --no-save -q 46 | 47 | install: clean 48 | R CMD INSTALL . 49 | 50 | project: 51 | xdg-open https://github.com/orgs/ropenscilabs/projects/2 52 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(dcmi_terms) 4 | export(depositsClient) 5 | export(deposits_metadata_template) 6 | export(deposits_services) 7 | export(figshare_categories) 8 | export(get_deposits_token) 9 | importFrom(R6,R6Class) 10 | importFrom(here,here) 11 | importFrom(utils,tar) 12 | importFrom(utils,zip) 13 | -------------------------------------------------------------------------------- /R/client-private-dcmi2host.R: -------------------------------------------------------------------------------- 1 | # Service-specific functions to insert deposits "metadata" field in 2 | # DCMI-compliant form into host metadata fields, including private client 3 | # methods. See #65. 4 | 5 | #' Method to convert client "metadata" (DCMI) field into one metadata parameter 6 | #' on host service. 7 | #' 8 | #' This is called on outgoing methods of deposit initiation and update. 9 | #' @noRd 10 | depositsClient$set ("private", "dcmi2host", function () { 11 | 12 | meta_json <- jsonlite::toJSON (self$metadata, auto_unbox = TRUE) 13 | meta_json <- paste0 ( 14 | "\\n\\n---start-deposits-meta---\\n", 15 | paste0 (meta_json), 16 | "\\n---end-deposits-meta---\\n" 17 | ) 18 | 19 | if (self$service == "zenodo") { 20 | 21 | private$metadata_service$metadata$notes <- paste0 ( 22 | private$metadata_service$metadata$notes, 23 | meta_json 24 | ) 25 | 26 | } else if (self$service == "figshare") { 27 | 28 | # Figshare should ideally go into "custom_fields", or 29 | # "custom_fields_list", but those are currently only used to auto-fill 30 | # from institutional-level settings, and can't be used for indivudual 31 | # deposits. 32 | 33 | private$metadata_service$description <- paste0 ( 34 | private$metadata_service$description, 35 | meta_json 36 | ) 37 | } 38 | 39 | invisible (self) 40 | }) 41 | 42 | #' Method to convert "metadata" (DCMI) field embedded into one host metadata 43 | #' parameter back into internal client "metadata" structure. 44 | #' 45 | #' This is called on incoming method of deposit retrieval, and only actually 46 | #' executed if the client has no local metadata. 47 | #' @noRd 48 | depositsClient$set ("private", "host2dcmi_internal", function () { 49 | 50 | if (!is.null (self$metadata)) { 51 | return (invisible (self)) 52 | } 53 | 54 | if (self$service == "zenodo") { 55 | field <- self$hostdata$metadata$notes 56 | } else if (self$service == "figshare") { 57 | field <- self$hostdata$description 58 | } 59 | 60 | if (length (field) == 0L) { 61 | return (invisible (self)) 62 | } 63 | 64 | ptn <- "^\\-{3}start\\-deposits\\-meta\\-{3}$" 65 | if (!grepl (ptn, field)) { 66 | return (invisible (self)) 67 | } 68 | 69 | # Figshare does not render "\n", only "\\n", and some of these double 70 | # backslashes end up repeated and need to be reduced here for JSON parsing. 71 | field <- condense_linebreaks (field) 72 | field <- strsplit (field, "\n") [[1]] 73 | i <- grep (ptn, field) 74 | j <- grep (gsub ("start", "end", ptn), field) 75 | 76 | if (length (i) == 1L && length (j) == 1L) { 77 | index <- seq (i + 1, j - 1) 78 | metadata <- paste0 (field [index], collapse = "") 79 | self$metadata <- jsonlite::fromJSON (metadata, simplifyVector = FALSE) 80 | } 81 | 82 | invisible (self) 83 | }) 84 | 85 | #' Remove the metadata produced in 'dcmi2host'. 86 | #' 87 | #' This is called as soon as a 'datapackage.json' file is uploaded. From that 88 | #' point on, metadata are stored and read from there, so no longer need to be 89 | #' stored in the host metadata field. 90 | #' @noRd 91 | depositsClient$set ("private", "remove_dcmi2host", function () { 92 | 93 | metadata <- validate_metadata ( 94 | self$metadata, 95 | gsub ("\\-sandbox$", "", self$service) 96 | ) 97 | metadata <- httptest2_created_timestamp (metadata) 98 | self$metadata <- metadata$dcmi 99 | private$metadata_service <- metadata$service 100 | 101 | # That service data will then *not* have the 'dcmi2host' field inserted, so 102 | # can be used to update directly. The "local_path" variable has to be 103 | # temporarily removed here to prevent update from erroring because 104 | # additional local files do not exist on remote deposit. 105 | local_path <- self$local_path 106 | self$local_path <- NULL 107 | self$deposit_update () 108 | self$local_path <- local_path 109 | 110 | invisible (self) 111 | }) 112 | -------------------------------------------------------------------------------- /R/deposits-package.R: -------------------------------------------------------------------------------- 1 | #' @keywords internal 2 | #' @importFrom R6 R6Class 3 | #' @importFrom here here 4 | #' @importFrom utils tar zip 5 | "_PACKAGE" 6 | 7 | # The following block is used by usethis to automatically manage 8 | # roxygen namespace tags. Modify with care! 9 | ## usethis namespace: start 10 | ## usethis namespace: end 11 | NULL 12 | -------------------------------------------------------------------------------- /R/desc-to-meta.R: -------------------------------------------------------------------------------- 1 | #' @title Check whether file is a .dcf file 2 | #' @param path Path to directory or file 3 | #' @return `TRUE` if file is a .dcf file, `FALSE` otherwise 4 | #' @noRd 5 | is_dcf <- function (path) { 6 | 7 | if (is.null (path)) { 8 | return (FALSE) 9 | } 10 | 11 | path <- fs::path_abs (path) 12 | 13 | if (fs::is_dir (path)) { 14 | path <- fs::path (path, "DESCRIPTION") 15 | } 16 | 17 | dcf_names <- c ("DESCRIPTION") # Can be extended 18 | if (!fs::file_exists (path)) { 19 | return (FALSE) 20 | } else if (!fs::path_file (path) %in% dcf_names) { 21 | return (FALSE) 22 | } 23 | 24 | desc <- tryCatch (read.dcf (path), error = function (e) NULL) 25 | ret <- all (c ("Package", "Title", "Version") %in% colnames (desc)) 26 | 27 | return (ret) 28 | } 29 | 30 | #' @title Get path to .dcf file if it exists 31 | #' @param path Path to directory or file 32 | #' @return Path to .dcf file, or NULL if no .dcf file can be found 33 | #' @noRd 34 | dcf_path <- function (path) { 35 | 36 | path <- fs::path_abs (path) 37 | 38 | if (fs::is_dir (path)) { 39 | path <- fs::path (path, "DESCRIPTION") 40 | } 41 | 42 | ret <- NULL 43 | if (is_dcf (path)) { 44 | ret <- path 45 | } 46 | return (ret) 47 | } 48 | 49 | desc_authors <- function (desc) { 50 | 51 | given <- family <- role <- email <- comment <- NA_character_ 52 | if ("Author" %in% names (desc)) { 53 | name <- desc$Author 54 | } else if ("Authors.R" %in% names (desc)) { 55 | auts <- eval (parse (text = desc$Authors.R)) 56 | given <- format (auts, include = "given") 57 | family <- format (auts, include = "family") 58 | name <- paste (given, family) 59 | role <- format (auts, include = "role") 60 | email <- format (auts, include = "email") 61 | comment <- format (auts, include = "comment") 62 | } 63 | 64 | res <- data.frame ( 65 | name = name, 66 | given = given, 67 | family = family, 68 | role = role, 69 | email = email, 70 | comment = comment 71 | ) 72 | 73 | # Get ORCID ID from comment field: 74 | res$orcid <- NA_character_ 75 | index <- grep ("orcid", res$comment, ignore.case = TRUE) 76 | if (length (index) > 0L) { 77 | orcid <- regmatches ( 78 | res$comment [index], 79 | gregexpr ("", res$comment [index]) 80 | ) 81 | orcid <- vapply (orcid, function (i) { 82 | if (length (i) == 0) { 83 | return (NA_character_) 84 | } else { 85 | return (i [1]) 86 | } 87 | }, character (1L)) 88 | orcid <- gsub ("^.*orcid.org\\/|>$", "", orcid) 89 | res$orcid [index] <- orcid 90 | } 91 | 92 | if (all (!is.na (res$role))) { 93 | res <- res [grep ("aut", res$role), ] 94 | } 95 | 96 | return (res) 97 | } 98 | 99 | desc_creators <- function (desc, service) { 100 | 101 | authors <- desc_authors (desc) 102 | 103 | creators <- lapply (seq_len (nrow (authors)), function (i) { 104 | res <- list (name = authors$name [i]) 105 | if (nzchar (authors$given [i])) { 106 | res$first_name <- authors$given [i] 107 | } 108 | if (nzchar (authors$family [i])) { 109 | res$last_name <- authors$family [i] 110 | } 111 | if (nzchar (authors$email [i])) { 112 | res$email <- authors$email [i] 113 | } 114 | if (!is.na (authors$orcid [i])) { 115 | res$orcid <- authors$orcid [i] 116 | } 117 | return (res) 118 | }) 119 | 120 | # in service-desc-meta.R: 121 | creators <- desc_creator_service (creators, service) 122 | 123 | return (creators) 124 | } 125 | -------------------------------------------------------------------------------- /R/figshare-categories.R: -------------------------------------------------------------------------------- 1 | #' Select figshare categories and return corresponding integer identifier. 2 | #' 3 | #' These identifiers should then be added in deposit metadata as, for example, 4 | #' `subject(categories=c(1,2))`. 5 | #' @family meta 6 | #' @export 7 | figshare_categories <- function () { 8 | 9 | url <- "https://api.figshare.com/v2/categories" 10 | req <- httr2::request (url) 11 | req <- httr2::req_method (req, "GET") 12 | resp <- httr2::req_perform (req) 13 | res <- httr2::resp_body_json (resp, simplifyVector = TRUE) 14 | 15 | # Then next path lists: 16 | paths <- lapply ( 17 | strsplit (res$path, "/"), 18 | function (i) i [which (nzchar (i))] 19 | ) 20 | 21 | # hard-code for 3-part hierarchy: 22 | res$p1 <- vapply (paths, function (i) i [1], character (1L)) 23 | res$p2 <- vapply (paths, function (i) i [2], character (1L)) 24 | 25 | # First split, the names of which are not encoded in the data, so taken here 26 | # from figshare itself: 27 | res <- split (res, f = as.factor (res$p1)) 28 | nms <- c ( 29 | "Agricultural, veterinary and food sciences", 30 | "Biological sciences", 31 | "Biomedical and clinical sciences", 32 | "Built environment and design", 33 | "Chemical sciences", 34 | "Commerce, management, tourism and services", 35 | "Creative arts and writing", 36 | "Earth sciences", 37 | "Economics", 38 | "Education", 39 | "Engineering", 40 | "Environmental sciences", 41 | "Health sciences", 42 | "History, heritage and archaeology", 43 | "Human society", 44 | "Indigenous studies", 45 | "Information and computing sciences", 46 | "Language, communication and culture", 47 | "Law and legal studies", 48 | "Mathematical sciences", 49 | "Philosophy and religious studies", 50 | "Physical sciences", 51 | "Psychology" 52 | ) 53 | stopifnot (length (nms) == length (res)) 54 | names (res) <- nms 55 | 56 | # Second split. The names of each sub-category are then the first items in 57 | # each group. 58 | res <- lapply (res, function (i) { 59 | res_i <- split (i, f = as.factor (i$p2)) 60 | names (res_i) <- vapply ( 61 | res_i, 62 | function (j) j$title [1], 63 | character (1L) 64 | ) 65 | res_i <- lapply (res_i, function (j) j [-1L, ]) 66 | return (res_i) 67 | }) 68 | 69 | if (!interactive () || is_deposits_test_env ()) { 70 | out <- lapply (res, function (i) do.call (rbind, i)) 71 | return (do.call (rbind, out)) 72 | } 73 | 74 | # ------ Interactive readline code to select category: ------ 75 | message ( 76 | "Choose a number corresponding to one of the ", 77 | "following categorical groups:" 78 | ) 79 | print (names (res), width = 20L) 80 | n1 <- as.integer (readline ("Number: ")) 81 | while (n1 < 1 || n1 > length (res)) { 82 | message ("Value must be between 1 and ", length (res)) 83 | n1 <- as.integer (readline ("Number: ")) 84 | } 85 | 86 | res_i <- res [[n1]] 87 | message ( 88 | "Choose a number corresponding to one of the ", 89 | "following sub-groups in that category:" 90 | ) 91 | print (names (res_i), width = 20L) 92 | n2 <- as.integer (readline ("Number: ")) 93 | while (n2 < 1 || n2 > length (res_i)) { 94 | message ("Value must be between 1 and ", length (res_i)) 95 | n2 <- as.integer (readline ("Number: ")) 96 | } 97 | 98 | res_ij <- res_i [[n2]] 99 | message ( 100 | "Finally, choose a number corresponding to one ", 101 | "of the following categories:" 102 | ) 103 | print (res_ij$title, width = 20L) 104 | n3 <- as.integer (readline ("Number: ")) 105 | while (n3 < 1 || n3 > length (res_ij)) { 106 | message ("Value must be between 1 and ", length (res_ij)) 107 | n3 <- as.integer (readline ("Number: ")) 108 | } 109 | 110 | cat_id <- res_ij$id [n3] 111 | message ("Figshare category id = ", cat_id) 112 | 113 | return (cat_id) 114 | } 115 | -------------------------------------------------------------------------------- /R/httptest2-mocks.R: -------------------------------------------------------------------------------- 1 | # This file contains functions used to standardise inputs and outputs from API 2 | # calls used by httptest2 in the test suite. Test environments are all flagged 3 | # by setting the environment variable, `DEPOSITS_TEST_ENV` to "true". These 4 | # functions have no effect in any other operating environment, including any 5 | # normal usage of the package. 6 | # 7 | # Within `httptest2`, they mostly standardise a variety of date and time stamps 8 | # placed upon request and return objects. This standardisation is necessary 9 | # because `httptest2` constructs path and object names with hashes of the 10 | # objects used in requests. These objects thus need to be entirely standardised 11 | # to ensure reproducible hashes. 12 | # 13 | # The functions are all prefixed with `httptest2_` to explicitly indicate what 14 | # they do, and this file is the only place in which the TEST_ENV environment 15 | # variable is checked. 16 | 17 | 18 | 19 | #' @description Standardise timestamps put on return objects by APIs to ensure 20 | #' consistent object hashes for `httptest`. Only activated in test environments 21 | #' in which `DEPOSITS_TEST_ENV` envvar is set. 22 | #' 23 | #' This is called in the main `deposit_retrieve()` method. 24 | #' @noRd 25 | 26 | httptest2_hostdata_timestamps <- function (hostdata, service) { 27 | 28 | if (Sys.getenv ("DEPOSITS_TEST_ENV") == "true") { 29 | 30 | mockdate <- "2022-01-01T00:00:00+00:00" 31 | 32 | if (service == "figshare") { 33 | 34 | hostdata$created_date <- hostdata$modified_date <- mockdate 35 | 36 | } else if (service == "zenodo") { 37 | 38 | if ("modified" %in% names (hostdata)) { 39 | hostdata$modified <- mockdate 40 | } 41 | if ("publication_date" %in% names (hostdata)) { 42 | hostdata$publication_date <- "2022-01-01" 43 | } 44 | if ("publication_date" %in% names (hostdata$metadata)) { 45 | hostdata$metadata$publication_date <- "2022-01-01" 46 | } 47 | } 48 | } 49 | 50 | return (hostdata) 51 | } 52 | 53 | #' @description Standardise timestamp of metadata "created" field. 54 | #' 55 | #' @noRd 56 | 57 | httptest2_created_timestamp <- function (metadata) { 58 | 59 | if (Sys.getenv ("DEPOSITS_TEST_ENV") == "true") { 60 | mockdate <- "2022-01-01T00:00:00+00:00" 61 | mockdate_short <- strftime (mockdate, "%Y-%m-%d") 62 | if ("created" %in% names (metadata)) { 63 | metadata [["created"]] <- mockdate 64 | } 65 | if ("created" %in% names (metadata$dcmi)) { 66 | metadata$dcmi [["created"]] <- mockdate 67 | } 68 | if ("created" %in% names (metadata$service)) { 69 | metadata$service [["created"]] <- mockdate 70 | } 71 | # publication_date inserted in zenodo embargo test: 72 | if ("publication_date" %in% names (metadata$service$metadata)) { 73 | metadata$service$metadata [["publication_date"]] <- mockdate_short 74 | } 75 | } 76 | 77 | return (metadata) 78 | } 79 | -------------------------------------------------------------------------------- /R/httr2-helpers.R: -------------------------------------------------------------------------------- 1 | 2 | create_httr2_helper <- function (url, headers, method) { 3 | 4 | req <- httr2::request (url) 5 | req <- httr2::req_headers (req, "Authorization" = headers) 6 | req <- httr2::req_method (req, method) 7 | 8 | return (req) 9 | } 10 | -------------------------------------------------------------------------------- /R/metadata-dcmi.R: -------------------------------------------------------------------------------- 1 | # Functions to convert metadata inputs into standard DCMI terms 2 | 3 | #' Get DCMI elements from definition file 4 | #' 5 | #' @return An \pkg{xml2} `xml_document` with the DCMI terms schema. 6 | #' @family meta 7 | #' @noRd 8 | dcmi_schema <- function () { 9 | 10 | path <- "extdata/dc/" 11 | schema <- "dcterms.xsd" 12 | elements <- "dc.xsd" 13 | 14 | read_one_xml <- function (path, file_name) { 15 | 16 | f <- system.file (fs::path (path, file_name), package = "deposits") 17 | if (!fs::file_exists (f)) { 18 | stop ("Schema file [", f, "] not found") 19 | } 20 | xml2::read_xml (f) 21 | } 22 | 23 | # The defined types of DCMI elements, each of which inherits from 24 | # 'substitutionGroup = "any"', and is prepended with "dc:" in the 25 | # 'substitionGroup' entries in the actual terms table. 26 | element_types <- read_one_xml (path, elements) 27 | element_types <- xml2::xml_find_all (element_types, "xs:element") 28 | element_types <- xml2::xml_attr (element_types, "name") 29 | element_types <- paste0 ("dc:", element_types) 30 | 31 | schema <- read_one_xml (path, schema) 32 | elements <- xml2::xml_find_all (schema, "xs:element") 33 | element_names <- xml2::xml_attr (elements, "name") 34 | element_groups <- xml2::xml_attr (elements, "substitutionGroup") 35 | 36 | # The following 'substitutionGroup' entries re-map directly into "dc:" 37 | # versions of the same: 38 | remaps <- c ( 39 | "coverage", 40 | "date", 41 | "description", 42 | "format", 43 | "identifier", 44 | "relation", 45 | "rights", 46 | "title" 47 | ) 48 | element_groups [element_groups %in% remaps] <- 49 | paste0 ("dc:", element_groups [element_groups %in% remaps]) 50 | 51 | data.frame ( 52 | name = element_names, 53 | group = element_groups 54 | ) 55 | } 56 | 57 | #' Get names of DCMI terms 58 | #' 59 | #' The Dublin Core Metadata Initiative defines a set of terms at 60 | #' \url{https://www.dublincore.org/specifications/dublin-core/dcmi-terms/}. 61 | #' 62 | #' @param term If specified, match term to official DCMI nomenclature, and 63 | #' return single match. 64 | #' @return A character vector of DCMI terms. 65 | #' @family meta 66 | #' @export 67 | dcmi_terms <- function (term = NULL) { 68 | 69 | if (!is.null (term)) { 70 | checkmate::assert_character (term, len = 1L) 71 | } 72 | 73 | element_names <- dcmi_schema ()$name 74 | 75 | if (!is.null (term)) { 76 | element_names <- 77 | grep (term, element_names, value = TRUE, ignore.case = TRUE) 78 | } 79 | 80 | if (length (element_names) == 0L) { 81 | element_names <- "" 82 | } 83 | 84 | return (element_names) 85 | } 86 | -------------------------------------------------------------------------------- /R/metadata-template.R: -------------------------------------------------------------------------------- 1 | #' Write an empty metadata template to local file 2 | #' 3 | #' The fields are those defined by the Dublin Core Metadata Initiative (DCMI), 4 | #' defined at 5 | #' \url{https://www.dublincore.org/specifications/dublin-core/dcmi-terms/}. The 6 | #' template produced by this function is in `json` format which can be manually 7 | #' edited to provide metadata for a deposit. 8 | #' 9 | #' @param filename Name or full path to local file where template is to be 10 | #' written. This file will be created. If a file of that name already exists, it 11 | #' must first be deleted. The file extension '.json' will be automatically 12 | #' appended. 13 | #' 14 | #' @return (Invisibly) `TRUE` if local file successfully created; otherwise 15 | #' `FALSE`. 16 | #' 17 | #' @examples 18 | #' filename <- tempfile (fileext = ".json") 19 | #' deposits_metadata_template (filename) 20 | #' # then edit that file to complete metadata 21 | #' @family meta 22 | #' @export 23 | deposits_metadata_template <- function (filename = NULL) { 24 | 25 | checkmate::assert_character (filename, len = 1L) 26 | filepath <- fs::path_dir (filename) 27 | checkmate::assert_directory_exists (filepath) 28 | fs::path_ext (filename) <- ".json" 29 | if (fs::file_exists (filename)) { 30 | stop ( 31 | "filename [", filename, "] already exists; please delete before ", 32 | "calling this function." 33 | ) 34 | } 35 | 36 | dc <- system.file (fs::path ("extdata", "dc", "schema-template.json"), 37 | package = "deposits" 38 | ) 39 | template <- jsonlite::read_json (dc, simplifyVector = FALSE) 40 | 41 | res <- tryCatch ( 42 | suppressWarnings ( 43 | jsonlite::write_json (template, 44 | filename, 45 | auto_unbox = TRUE, 46 | pretty = TRUE 47 | ) 48 | ), 49 | error = function (e) e 50 | ) 51 | 52 | if (methods::is (res, "simpleError")) { 53 | stop ("Error with metadata: ", res$message) 54 | } 55 | 56 | message ( 57 | "Edit the file [", 58 | filename, 59 | "] and remove everything except the metadata fields you require.\n", 60 | "The filename may be then passed as the 'metadata' argument to a ", 61 | "'deposits' client." 62 | ) 63 | 64 | invisible (!methods::is (res, "error")) 65 | } 66 | -------------------------------------------------------------------------------- /R/service-desc-meta.R: -------------------------------------------------------------------------------- 1 | # Service-specific functions called from 'desc-to-meta.R' 2 | 3 | #' Convert character license strings to required figshare format of integer 4 | #' values. This function has no effect for any other service. 5 | #' @noRd 6 | desc_license <- function (desc, service) { 7 | 8 | ret <- desc$License 9 | 10 | if (service == "figshare") { 11 | # url <- "https://api.figshare.com/v2/licenses" 12 | # cli <- depositsClient$new (service = "figshare") 13 | # req <- create_httr2_helper (url, cli$headers$Authorization, "GET") 14 | # resp <- httr2::req_perform (req) 15 | # licenses <- httr2::resp_body_json (resp) 16 | # license <- do.call (rbind, licenses) 17 | licenses <- data.frame ( 18 | value = 1:7, 19 | name = c ( 20 | "CC\\sBY\\s4\\.0", 21 | "CC0", 22 | "MIT", 23 | "GPL", 24 | "GPL(.*?)2", 25 | "GPL(.*?)3", 26 | "Apache\\s2" 27 | ) 28 | ) 29 | index <- vapply ( 30 | licenses$name, 31 | function (i) grepl (i, ret, ignore.case = TRUE), 32 | logical (1L) 33 | ) 34 | ret <- NULL 35 | if (any (index)) { 36 | ret <- max (which (index)) 37 | } 38 | } 39 | 40 | return (ret) 41 | } 42 | 43 | desc_creator_service <- function (creators, service) { 44 | 45 | if (service == "zenodo") { 46 | # Zenodo only has "name" and "orcid", so need to 47 | # remove "first_name", "last_name", and "email": 48 | creators <- lapply (creators, function (i) { 49 | i$first_name <- i$last_name <- i$email <- NULL 50 | return (i) 51 | }) 52 | } 53 | 54 | return (creators) 55 | } 56 | 57 | #' Add additional fields required by Figshare if they are present in DESC file. 58 | #' 59 | #' These fields include categories and keywords, and are placed in the 'subject' 60 | #' metadata item. 61 | #' 62 | #' @param meta Initial metadata from description file. 63 | #' @noRd 64 | desc_subjects_service <- function (meta, descfile, service) { 65 | 66 | if (service == "figshare") { 67 | 68 | fs_cat <- grep ( 69 | "figsharecategor", 70 | names (descfile), 71 | ignore.case = TRUE 72 | ) 73 | 74 | if (length (fs_cat) == 1L) { 75 | 76 | cats <- strsplit (descfile [[fs_cat]], split = ",") 77 | cats <- as.integer (cats [[1]]) 78 | meta$subject <- list (categories = as.list (cats)) 79 | } 80 | 81 | fs_kw <- grep ("keyword", names (descfile), ignore.case = TRUE) 82 | if (length (fs_kw) == 1L) { 83 | 84 | kws <- strsplit (descfile [[fs_kw]], split = ",") [[1]] 85 | kws <- as.list (sub ("^\\s+|\\s+$", "", kws)) 86 | 87 | if ("subject" %in% names (meta)) { 88 | meta$subject$keywords <- kws 89 | } else { 90 | meta$subect <- list (keywords = kws) 91 | } 92 | } 93 | } 94 | 95 | return (meta) 96 | } 97 | -------------------------------------------------------------------------------- /R/service-urls.R: -------------------------------------------------------------------------------- 1 | #' Get URL of deposit service 2 | #' 3 | #' @param cli Deposits client with 'url_base' and 'service' fields. 4 | #' @param deposit_id Optional identifier of specified deposit. If specified, 5 | #' return URL to that deposit, otherwise return generic URL to particular 6 | #' service, used to create or list deposits. 7 | #' @param private Figshare API URLs differ for public articles by having the 8 | #' "account" sub-domain removed. This flag can be used to force insertion of 9 | #' this private sub-domain for methods, such as new article creation, which 10 | #' nevertheless require it. 11 | #' @return URL 12 | #' @noRd 13 | 14 | get_service_url <- function (cli, deposit_id = NULL, private = TRUE) { 15 | 16 | subdom <- "" 17 | if (cli$service == "figshare") { 18 | 19 | subdom <- "articles" # public articles 20 | if (private) { 21 | subdom <- "account/articles" 22 | } else { 23 | cli$deposits_list () 24 | if (!is.null (deposit_id) && !is.null (cli$deposits$id)) { 25 | if (deposit_id %in% cli$deposits$id) { 26 | subdom <- "account/articles" # private articles 27 | } 28 | } 29 | } 30 | 31 | } else if (cli$service == "zenodo") { 32 | 33 | subdom <- "deposit/depositions" 34 | } 35 | 36 | url <- paste0 (cli$url_base, subdom) 37 | 38 | if (!is.null (deposit_id)) { 39 | checkmate::assert_int (deposit_id) 40 | url <- paste0 (url, "/", deposit_id) 41 | } 42 | 43 | return (url) 44 | } 45 | -------------------------------------------------------------------------------- /R/tokens.R: -------------------------------------------------------------------------------- 1 | #' Retrieve a token for a specified deposits service. 2 | #' 3 | #' Tokens should be stored as local environment variables, optionally defined in 4 | #' a `~/.Renviron` file, and should contain the name of the desired deposits 5 | #' service. 6 | #' 7 | #' @param service Name of desired service; must be a value in the "name" column 8 | #' of \link{deposits_services}. 9 | #' @param sandbox If `TRUE`, retrieve token for sandbox, rather than actual API. 10 | #' @return API token for nominated service. 11 | #' 12 | #' @examples 13 | #' \dontrun{ 14 | #' token <- get_deposits_token (service = "figshare") 15 | #' } 16 | #' @family auth 17 | #' @export 18 | get_deposits_token <- function (service = NULL, sandbox = FALSE) { 19 | 20 | checkmate::assert_character (service, len = 1L) 21 | 22 | service <- gsub ("\\-", ".*", service) 23 | e <- Sys.getenv () 24 | e <- e [grep (service, names (e), ignore.case = TRUE)] 25 | if (length (e) != 1L) { 26 | if (grepl ("^zenodo$", service, ignore.case = TRUE)) { 27 | if (sandbox && any (grepl ("sandbox", names (e), ignore.case = TRUE))) { 28 | e <- e [grep ("sandbox", names (e), ignore.case = TRUE)] 29 | } else { 30 | e <- e [which (!grepl ("sandbox", names (e), ignore.case = TRUE))] 31 | } 32 | } 33 | } 34 | 35 | token <- unique (e) 36 | 37 | if (length (token) == 0L) { 38 | stop ("No token found for [", service, "] service.", 39 | call. = FALSE 40 | ) 41 | } 42 | if (length (token) != 1L) { 43 | stop ("No unambiguous token found for [", service, "] service.", 44 | call. = FALSE 45 | ) 46 | } 47 | 48 | return (token) 49 | } 50 | -------------------------------------------------------------------------------- /R/upload-figshare.R: -------------------------------------------------------------------------------- 1 | #' Upload a file to a nominated figshare article 2 | #' 3 | #' \url{https://docs.figshare.com/#upload_files_example_upload_on_figshare} 4 | #' 5 | #' @param article_id The generic 'deposit_id' parameter passed to the deposits 6 | #' client, where deposits in figshare are called "articles". 7 | #' @param url The generic endpoint for figshare articles. 8 | #' @param headers Generic header including the OAuth token. 9 | #' @param path Path to local file to be uploaded. 10 | #' @noRd 11 | upload_figshare_file <- function (article_id, url, headers, path) { 12 | 13 | article_url <- sprintf ("%s/%s", url, article_id) 14 | 15 | x <- figshare_upload_url (article_id, url, headers, path) 16 | upload_url <- x$upload_url 17 | file_id <- x$id 18 | # upload_token <- x$upload_token 19 | 20 | flist <- figshare_upload_parts (upload_url, headers, path) 21 | nparts <- length (flist) 22 | 23 | # upload parts: 24 | for (i in seq (nparts)) { 25 | 26 | url_i <- sprintf ("%s/%s", upload_url, i) 27 | req <- create_httr2_helper (url_i, headers$Authorization, "PUT") 28 | req$headers <- c (req$headers, 29 | "Content-Type" = "application/octet-stream" 30 | ) 31 | req <- httr2::req_body_file ( 32 | req, 33 | path = path 34 | ) 35 | resp <- httr2::req_perform (req) 36 | httr2::resp_check_status (resp) 37 | } 38 | 39 | # complete upload 40 | file_url <- sprintf ("%s/files/%s", article_url, file_id) 41 | req <- create_httr2_helper (file_url, headers$Authorization, "POST") 42 | resp <- httr2::req_perform (req) 43 | httr2::resp_check_status (resp) 44 | 45 | fs::file_delete (flist) 46 | 47 | # and check article data: 48 | req <- create_httr2_helper (article_url, headers$Authorization, "GET") 49 | resp <- httr2::req_perform (req) 50 | httr2::resp_check_status (resp) 51 | 52 | # return value is full hostdata with updated files component 53 | return (httr2::resp_body_json (resp, simplifyVector = TRUE)) 54 | } 55 | 56 | figshare_upload_url <- function (id, url, headers, path) { 57 | 58 | path <- fs::path (path) 59 | md5 <- unname (tools::md5sum (path)) 60 | s <- fs::file_size (path) 61 | body <- jsonlite::toJSON ( 62 | data.frame ( 63 | md5 = md5, 64 | name = basename (path), 65 | size = as.integer (s) 66 | ), 67 | pretty = FALSE, 68 | auto_unbox = TRUE 69 | ) 70 | body <- gsub ("^\\[|\\]$", "", paste0 (body)) 71 | 72 | url <- paste0 (url, "/", id, "/files") 73 | 74 | # First get upload location: 75 | req <- create_httr2_helper (url, headers$Authorization, "POST") 76 | req$headers <- c (req$headers, "Content-Type" = "application/json") 77 | req <- httr2::req_body_raw (req, body = paste0 (body)) 78 | 79 | resp <- httr2::req_perform (req) 80 | httr2::resp_check_status (resp) 81 | 82 | location <- httr2::resp_body_json (resp) 83 | 84 | # Then a second call to get upload URL: 85 | file_id <- gsub ("^.*\\/", "", location) 86 | url <- paste0 (url, "/", file_id) 87 | 88 | req <- create_httr2_helper (url, headers$Authorization, "GET") 89 | resp <- httr2::req_perform (req) 90 | httr2::resp_check_status (resp) 91 | httr2::resp_body_json (resp) 92 | } 93 | 94 | figshare_upload_parts <- function (upload_url, headers, path) { 95 | 96 | req <- create_httr2_helper (upload_url, headers$Authorization, "GET") 97 | resp <- httr2::req_perform (req) 98 | httr2::resp_check_status (resp) 99 | x <- httr2::resp_body_json (resp, simplifyVector = TRUE) 100 | 101 | parts <- x$parts 102 | part_size <- parts$endOffset [1] + 1 103 | tmpdir <- fs::path_dir (path) 104 | 105 | withr::with_dir ( 106 | tmpdir, 107 | system (paste ("split -b", part_size, path, "part_", "--numeric=1")) 108 | ) 109 | 110 | fs::dir_ls (tmpdir, regexp = "part\\_[0-9]+$") 111 | } 112 | 113 | #' Current only called from `deposit_delete_file()` method via private 114 | #' `delete_file` method. 115 | #' @param path Always just the file name. 116 | #' @noRd 117 | figshare_delete_file <- function (article_id, service_url, files, headers, path) { 118 | 119 | f <- fs::path_file (path) 120 | if (!f %in% files$name) { 121 | stop ( 122 | "File [", f, "] is not held on deposit#", article_id, 123 | call. = FALSE 124 | ) 125 | } 126 | 127 | file_id <- files$id [files$name == f] 128 | del_url <- paste0 (service_url, "/", article_id, "/files/", file_id) 129 | 130 | req <- create_httr2_helper (del_url, headers$Authorization, "DELETE") 131 | resp <- httr2::req_perform (req) 132 | httr2::resp_check_status (resp) 133 | } 134 | -------------------------------------------------------------------------------- /R/upload-zenodo.R: -------------------------------------------------------------------------------- 1 | #' Upload a file to a nominated zenodo article 2 | #' 3 | #' @param deposit_id 'id' parameter passed to the deposits 4 | #' client. 5 | #' @param url The generic endpoint for zenodo articles. 6 | #' @param headers Generic header including the OAuth token. 7 | #' @param path Path to local file to be uploaded. 8 | #' @noRd 9 | upload_zenodo_file <- function (deposit_id, url, headers, path) { 10 | 11 | bucket_link <- get_zenodo_bucket_link (deposit_id, url, headers) 12 | 13 | filename <- basename (path) 14 | file_url <- paste0 (bucket_link, "/", filename) 15 | 16 | req <- create_httr2_helper (file_url, headers$Authorization, "PUT") 17 | req$headers <- c (req$headers, "Content-Type" = "application/octet-stream") 18 | req <- httr2::req_body_file ( 19 | req, 20 | path = path 21 | ) 22 | resp <- httr2::req_perform (req) 23 | httr2::resp_check_status (resp) 24 | 25 | return (httr2::resp_body_json (resp, simplifyVector = TRUE)) 26 | } 27 | 28 | get_zenodo_bucket_link <- function (deposit_id, url, headers) { 29 | 30 | url <- sprintf ("%s/%s", url, deposit_id) 31 | 32 | req <- create_httr2_helper (url, headers$Authorization, "GET") 33 | resp <- httr2::req_perform (req) 34 | httr2::resp_check_status (resp) 35 | 36 | resp <- httr2::resp_body_json (resp) 37 | 38 | return (resp$links$bucket) 39 | } 40 | 41 | zenodo_delete_file <- function (article_id, service_url, files, headers, path) { 42 | 43 | f <- fs::path_file (path) 44 | if (!f %in% files$filename) { 45 | stop ( 46 | "File [", f, "] is not held on deposit#", article_id, 47 | call. = FALSE 48 | ) 49 | } 50 | 51 | file_id <- files$id [files$filename == f] 52 | del_url <- paste0 (service_url, "/", article_id, "/files/", file_id) 53 | 54 | req <- create_httr2_helper (del_url, headers$Authorization, "DELETE") 55 | resp <- httr2::req_perform (req) 56 | httr2::resp_check_status (resp) 57 | } 58 | -------------------------------------------------------------------------------- /R/utils.R: -------------------------------------------------------------------------------- 1 | #' Is a file binary? 2 | #' 3 | #' Taken from the {knitrdata} package: 4 | #' https://github.com/dmkaplan2000/knitrdata/blob/master/R/utils.R 5 | #' See the above link for full documentation. The following quote is relevant 6 | #' "This works well for standard ASCII text, but it may be less effective for 7 | #' complex UTF8 text (e.g., Chinese)." 8 | #' Copyright: David M. Kaplan \email{dmkaplan2000@@gmail.com} 9 | #' 10 | #' The following parameter documentation entries are taken directly from 11 | #' {knitrdata}: 12 | #' @param file The path to the file to be examined 13 | #' @param bin.ints List of integers with the ASCII values of control characters 14 | #' that are to be considered when when looking for signs a file is binary. 15 | #' Default includes most ASCII control characters except things like NULL, 16 | #' LF, CR and HT that might actually appear in an ASCII file. 17 | #' @param nbytes Number of bytes to read in from the beginning of the file. 18 | #' @param nbin An integer indicating the threshold on the number of control 19 | #' characters above which a file is considered binary. Defaults to 2. 20 | #' @noRd 21 | 22 | is_file_binary <- function (file, bin_ints = c (1:8, 14:25), 23 | nbytes = 1000, nbin = 2) { 24 | 25 | x <- as.integer (readBin (file, "raw", nbytes)) 26 | n <- sum (x %in% bin_ints) 27 | 28 | return (n > nbin) 29 | } 30 | 31 | is_deposits_test_env <- function () { 32 | Sys.getenv ("DEPOSITS_TEST_ENV") == "true" 33 | } 34 | 35 | deposit_timestamp <- function (datetime) { 36 | 37 | checkmate::assert_class (datetime, "POSIXct") 38 | datetime <- format.POSIXct (datetime, "%Y-%m-%dT%H:%M:%S%z", usetz = FALSE) 39 | # change terminal "+0000" to "+00:00": 40 | ptn <- regmatches (datetime, regexpr ("[0-9]{2}$", datetime)) 41 | datetime <- gsub (paste0 (ptn, "$"), paste0 (":", ptn), datetime) 42 | 43 | return (datetime) 44 | } 45 | 46 | condense_linebreaks <- function (txt) { 47 | for (n in 4:1) { 48 | bs <- rep ("\\", n) 49 | ptn <- paste0 (paste0 (bs, collapse = ""), "n") 50 | txt <- gsub (ptn, "\n", txt) 51 | } 52 | return (txt) 53 | } 54 | 55 | #' Extract 'service' parameter from metadata if not otherwise specified. 56 | #' @noRd 57 | service_from_metadata <- function (metadata, service = NULL) { 58 | 59 | if (!"identifier" %in% names (metadata)) { 60 | return (NULL) 61 | } 62 | 63 | id <- metadata$identifier 64 | srv <- regmatches ( 65 | id, 66 | regexpr ("(\\.|\\/)[a-zA-z]+\\.[0-9]+$", id) 67 | ) 68 | srv <- gsub ("^\\.|\\/|\\.[0-9]+$", "", srv) 69 | 70 | if (!is.null (srv)) { 71 | service <- srv 72 | } 73 | 74 | return (service) 75 | } 76 | 77 | #' Compare local and remote md5sums to determine whether files differ 78 | #' @noRd 79 | md5sums_are_same <- function (path, 80 | hostdata, 81 | name_field, 82 | service, 83 | file_exists = FALSE, 84 | quiet = FALSE) { 85 | 86 | md5_local <- unname (tools::md5sum (path)) 87 | 88 | md5_remote <- NULL 89 | path_file <- fs::path_file (path) 90 | host_files <- hostdata$files 91 | i <- match (path_file, host_files [[name_field]]) 92 | if (length (i) > 0L) { 93 | md5_field <- service_md5_field (service) # in services.R 94 | md5_remote <- host_files [[md5_field]] [i] 95 | } 96 | 97 | res <- identical (md5_local, md5_remote) 98 | 99 | if (!quiet) { 100 | if (res) { 101 | message ( 102 | "Local file at [", 103 | path, 104 | "] is identical on host and will not be uploaded." 105 | ) 106 | } else if (file_exists) { 107 | message ( 108 | "Local file at [", 109 | path, 110 | "] has changed and will now be uploaded." 111 | ) 112 | } 113 | } 114 | 115 | return (res) 116 | } 117 | 118 | compress_from_filename <- function (filename) { 119 | 120 | compress <- "no" 121 | if (grepl ("\\.zip$", filename)) { 122 | compress <- "zip" 123 | } else if (grepl ("\\.tar\\.gz$", filename)) { 124 | compress <- "tar" 125 | } 126 | 127 | return (compress) 128 | } 129 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: https://ropenscilabs.github.io/deposits 2 | 3 | figures: 4 | dev: grDevices::png 5 | 6 | reference: 7 | - title: Deposits client 8 | contents: 9 | - has_concept("client") 10 | - title: Authentication 11 | contents: 12 | - has_concept("auth") 13 | - title: Metadata 14 | contents: 15 | - has_concept("meta") 16 | - title: Miscellaneous 17 | contents: 18 | - has_concept("misc") 19 | -------------------------------------------------------------------------------- /data-raw/get-dcmi-xml.R: -------------------------------------------------------------------------------- 1 | 2 | # From https://www.dublincore.org/schemas/xmls/ 3 | 4 | urls <- c ( 5 | "https://www.dublincore.org/schemas/xmls/qdc/dc.xsd", 6 | "https://www.dublincore.org/schemas/xmls/qdc/dcterms.xsd", 7 | "https://www.dublincore.org/schemas/xmls/qdc/dcmitype.xsd" 8 | ) 9 | 10 | for (u in urls) { 11 | f <- file.path (here::here (), "inst", "extdata", "dc", basename (u)) 12 | download.file (u, f) 13 | } 14 | -------------------------------------------------------------------------------- /data-raw/get-zenodo-licenses.R: -------------------------------------------------------------------------------- 1 | token <- Sys.getenv ("ZENODO_TOKEN") 2 | url <- "https://zenodo.org/api/licenses" 3 | headers <- list (Authorization = paste0 ("Bearer ", token)) 4 | req <- httr2::request (url) 5 | req <- httr2::req_method (req, "GET") 6 | req <- httr2::req_url_query (req, size = 1000) 7 | resp <- httr2::req_perform (req) 8 | resp_body <- httr2::resp_body_json (resp, simplify = TRUE) 9 | 10 | lic <- resp_body$hits$hits [, c ("id", "title", "links")] 11 | lic$title <- unlist (lic$title) 12 | lic$links <- unlist (lic$links) 13 | names (lic) [3] <- "url" 14 | 15 | path <- fs::path (here::here (), "inst", "extdata", "zenodo", "zenodo_licenses.csv") 16 | write.csv (lic, file = path, row.names = FALSE, fileEncoding = "UTF-8") 17 | -------------------------------------------------------------------------------- /inst/extdata/dc/dc.xsd: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | DCMES 1.1 XML Schema 11 | XML Schema for http://purl.org/dc/elements/1.1/ namespace 12 | 13 | Created 2008-02-11 14 | 15 | Created by 16 | 17 | Tim Cole (t-cole3@uiuc.edu) 18 | Tom Habing (thabing@uiuc.edu) 19 | Jane Hunter (jane@dstc.edu.au) 20 | Pete Johnston (p.johnston@ukoln.ac.uk), 21 | Carl Lagoze (lagoze@cs.cornell.edu) 22 | 23 | This schema declares XML elements for the 15 DC elements from the 24 | http://purl.org/dc/elements/1.1/ namespace. 25 | 26 | It defines a complexType SimpleLiteral which permits mixed content 27 | and makes the xml:lang attribute available. It disallows child elements by 28 | use of minOcccurs/maxOccurs. 29 | 30 | However, this complexType does permit the derivation of other complexTypes 31 | which would permit child elements. 32 | 33 | All elements are declared as substitutable for the abstract element any, 34 | which means that the default type for all elements is dc:SimpleLiteral. 35 | 36 | 37 | 38 | 39 | 40 | 41 | 43 | 44 | 45 | 46 | 47 | 48 | This is the default type for all of the DC elements. 49 | It permits text content only with optional 50 | xml:lang attribute. 51 | Text is allowed because mixed="true", but sub-elements 52 | are disallowed because minOccurs="0" and maxOccurs="0" 53 | are on the xs:any tag. 54 | 55 | This complexType allows for restriction or extension permitting 56 | child elements. 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | This group is included as a convenience for schema authors 92 | who need to refer to all the elements in the 93 | http://purl.org/dc/elements/1.1/ namespace. 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | This complexType is included as a convenience for schema authors who need to define a root 108 | or container element for all of the DC elements. 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /inst/extdata/dc/dcmitype.xsd: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | DCMI Type Vocabulary XML Schema 11 | XML Schema for http://purl.org/dc/dcmitype/ namespace 12 | 13 | Created 2008-02-11 14 | 15 | Created by 16 | 17 | Tim Cole (t-cole3@uiuc.edu) 18 | Tom Habing (thabing@uiuc.edu) 19 | Jane Hunter (jane@dstc.edu.au) 20 | Pete Johnston (p.johnston@ukoln.ac.uk), 21 | Carl Lagoze (lagoze@cs.cornell.edu) 22 | 23 | This schema defines a simpleType which enumerates 24 | the allowable values for the DCMI Type Vocabulary. 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /inst/httptest2/redact.R: -------------------------------------------------------------------------------- 1 | function (resp) { 2 | 3 | resp <- httptest2::gsub_response ( 4 | resp, 5 | "https://api.figshare.com/v2/account/articles/", 6 | "api/articles/", 7 | fixed = TRUE 8 | ) 9 | 10 | resp <- httptest2::gsub_response ( 11 | resp, 12 | "https://api.figshare.com/v2/", 13 | "api/", 14 | fixed = TRUE 15 | ) 16 | 17 | resp <- httptest2::gsub_response ( 18 | resp, 19 | "figshare.com/upload/", 20 | "up/", 21 | fixed = TRUE 22 | ) 23 | 24 | resp <- httptest2::gsub_response ( 25 | resp, 26 | "https://sandbox.zenodo.org/api/", 27 | "sbapi/", 28 | fixed = TRUE 29 | ) 30 | 31 | ptn <- paste0 (rep ("[a-z0-9]*", 5), collapse = "\\-") 32 | resp <- httptest2::gsub_response ( 33 | resp, 34 | paste0 ("(files|fup\\-eu\\-west\\-1\\.up)\\/", ptn, "/"), 35 | "files/hash/", 36 | fixed = FALSE 37 | ) 38 | 39 | # Timestamp pattern: 40 | ptn <- "[0-9]{4}\\-[0-9]{2}\\-[0-9]{2}T[0-9]{2}\\:[0-9]{2}\\:[0-9]{2}\\.[0-9]+" 41 | resp <- httptest2::gsub_response ( 42 | resp, 43 | ptn, 44 | "2022-01-01T00:00:00", 45 | fixed = FALSE 46 | ) 47 | 48 | # dates without times: 49 | ptn <- "[0-9]{4}\\-[0-9]{2}\\-[0-9]{2}" 50 | resp <- httptest2::gsub_response ( 51 | resp, 52 | ptn, 53 | "2022-01-01", 54 | fixed = FALSE 55 | ) 56 | 57 | # times without dates: 58 | ptn <- "[0-9]{2}\\:[0-9]{2}\\:[0-9]{2}" 59 | resp <- httptest2::gsub_response ( 60 | resp, 61 | ptn, 62 | "00:00:00", 63 | fixed = FALSE 64 | ) 65 | 66 | return (resp) 67 | } 68 | -------------------------------------------------------------------------------- /man/dcmi_terms.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/metadata-dcmi.R 3 | \name{dcmi_terms} 4 | \alias{dcmi_terms} 5 | \title{Get names of DCMI terms} 6 | \usage{ 7 | dcmi_terms(term = NULL) 8 | } 9 | \arguments{ 10 | \item{term}{If specified, match term to official DCMI nomenclature, and 11 | return single match.} 12 | } 13 | \value{ 14 | A character vector of DCMI terms. 15 | } 16 | \description{ 17 | The Dublin Core Metadata Initiative defines a set of terms at 18 | \url{https://www.dublincore.org/specifications/dublin-core/dcmi-terms/}. 19 | } 20 | \seealso{ 21 | Other meta: 22 | \code{\link{deposits_metadata_template}()}, 23 | \code{\link{figshare_categories}()} 24 | } 25 | \concept{meta} 26 | -------------------------------------------------------------------------------- /man/deposits-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/deposits-package.R 3 | \docType{package} 4 | \name{deposits-package} 5 | \alias{deposits} 6 | \alias{deposits-package} 7 | \title{deposits: A universal client for depositing and accessing research data anywhere} 8 | \description{ 9 | A universal client for depositing and accessing research data anywhere. Currently supported services are zenodo and figshare. 10 | } 11 | \seealso{ 12 | Useful links: 13 | \itemize{ 14 | \item \url{https://docs.ropensci.org/deposits/} 15 | \item Report bugs at \url{https://github.com/ropenscilabs/deposits/issues} 16 | } 17 | 18 | } 19 | \author{ 20 | \strong{Maintainer}: Mark Padgham \email{mark.padgham@email.com} (\href{https://orcid.org/0000-0003-2172-5265}{ORCID}) 21 | 22 | } 23 | \keyword{internal} 24 | -------------------------------------------------------------------------------- /man/deposits_metadata_template.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/metadata-template.R 3 | \name{deposits_metadata_template} 4 | \alias{deposits_metadata_template} 5 | \title{Write an empty metadata template to local file} 6 | \usage{ 7 | deposits_metadata_template(filename = NULL) 8 | } 9 | \arguments{ 10 | \item{filename}{Name or full path to local file where template is to be 11 | written. This file will be created. If a file of that name already exists, it 12 | must first be deleted. The file extension '.json' will be automatically 13 | appended.} 14 | } 15 | \value{ 16 | (Invisibly) \code{TRUE} if local file successfully created; otherwise 17 | \code{FALSE}. 18 | } 19 | \description{ 20 | The fields are those defined by the Dublin Core Metadata Initiative (DCMI), 21 | defined at 22 | \url{https://www.dublincore.org/specifications/dublin-core/dcmi-terms/}. The 23 | template produced by this function is in \code{json} format which can be manually 24 | edited to provide metadata for a deposit. 25 | } 26 | \examples{ 27 | filename <- tempfile (fileext = ".json") 28 | deposits_metadata_template (filename) 29 | # then edit that file to complete metadata 30 | } 31 | \seealso{ 32 | Other meta: 33 | \code{\link{dcmi_terms}()}, 34 | \code{\link{figshare_categories}()} 35 | } 36 | \concept{meta} 37 | -------------------------------------------------------------------------------- /man/deposits_services.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/service-functions.R 3 | \name{deposits_services} 4 | \alias{deposits_services} 5 | \title{List all deposits services and associated URLs} 6 | \usage{ 7 | deposits_services() 8 | } 9 | \value{ 10 | A \code{data.frame} with \code{name} and \code{url} values for each accessible 11 | service. 12 | } 13 | \description{ 14 | List all deposits services and associated URLs 15 | } 16 | \examples{ 17 | s <- deposits_services () 18 | } 19 | \concept{misc} 20 | -------------------------------------------------------------------------------- /man/figshare_categories.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/figshare-categories.R 3 | \name{figshare_categories} 4 | \alias{figshare_categories} 5 | \title{Select figshare categories and return corresponding integer identifier.} 6 | \usage{ 7 | figshare_categories() 8 | } 9 | \description{ 10 | These identifiers should then be added in deposit metadata as, for example, 11 | \code{subject(categories=c(1,2))}. 12 | } 13 | \seealso{ 14 | Other meta: 15 | \code{\link{dcmi_terms}()}, 16 | \code{\link{deposits_metadata_template}()} 17 | } 18 | \concept{meta} 19 | -------------------------------------------------------------------------------- /man/get_deposits_token.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tokens.R 3 | \name{get_deposits_token} 4 | \alias{get_deposits_token} 5 | \title{Retrieve a token for a specified deposits service.} 6 | \usage{ 7 | get_deposits_token(service = NULL, sandbox = FALSE) 8 | } 9 | \arguments{ 10 | \item{service}{Name of desired service; must be a value in the "name" column 11 | of \link{deposits_services}.} 12 | 13 | \item{sandbox}{If \code{TRUE}, retrieve token for sandbox, rather than actual API.} 14 | } 15 | \value{ 16 | API token for nominated service. 17 | } 18 | \description{ 19 | Tokens should be stored as local environment variables, optionally defined in 20 | a \verb{~/.Renviron} file, and should contain the name of the desired deposits 21 | service. 22 | } 23 | \examples{ 24 | \dontrun{ 25 | token <- get_deposits_token (service = "figshare") 26 | } 27 | } 28 | \concept{auth} 29 | -------------------------------------------------------------------------------- /tests/script.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | # Script to filter repo of all commit histories made by constantly over-writing 4 | # httptest2 results. First list all testthat sub-directories traced by git, as 5 | # returned from the '--analyze' function of 'git-filter-repo' 6 | git-filter-repo --analyze 7 | cp .git/filter-repo/analysis/directories-all-sizes.txt . 8 | DIRS=($(cat directories-all-sizes.txt | \ 9 | awk -F"tests/testthat/" '{ print $2 }' | \ 10 | awk '!/[/]|^$/ { print $1 }' | \ 11 | sort)) 12 | rm directories-all-sizes.txt 13 | 14 | # Then destructively remove all commits from all listed sub-directories: 15 | for d in "${DIRS[@]}"; do 16 | echo "$d"; 17 | git-filter-repo --path tests/testthat/"$d" --invert-paths 18 | done 19 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library (testthat) 2 | library (httptest2) 3 | library (deposits) 4 | 5 | test_check ("deposits") 6 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/client.md: -------------------------------------------------------------------------------- 1 | # print figshare 2 | 3 | Code 4 | print(cli) 5 | Output 6 | 7 | deposits service : figshare 8 | url_base : https://api.figshare.com/v2/ 9 | Current deposits : 1 (see 'deposits' element for details) 10 | 11 | hostdata : 12 | metadata : 13 | 14 | --- 15 | 16 | Code 17 | cli$deposits_methods() 18 | Output 19 | List of methods for a deposits client: 20 | 21 | - deposit_add_resource 22 | - deposit_delete 23 | - deposit_delete_file 24 | - deposit_download_file 25 | - deposit_embargo 26 | - deposit_fill_metadata 27 | - deposit_new 28 | - deposit_prereserve_doi 29 | - deposit_publish 30 | - deposit_retrieve 31 | - deposit_service 32 | - deposit_update 33 | - deposit_upload_file 34 | - deposit_version 35 | - deposits_list 36 | - deposits_methods 37 | - deposits_search 38 | 39 | see `?depositsClient` for full details of all methods. 40 | 41 | --- 42 | 43 | Code 44 | print(cli) 45 | Output 46 | 47 | deposits service : figshare 48 | url_base : https://api.figshare.com/v2/ 49 | Current deposits : 5 (see 'deposits' element for details) 50 | 51 | url_service : https://my.deposit 52 | deposit id : 1 53 | hostdata : list with 1 elements 54 | metadata : 1 terms (see 'metadata' element for details) 55 | 56 | # print figshare with local_path 57 | 58 | Code 59 | print(cli) 60 | Output 61 | 62 | deposits service : figshare 63 | url_base : https://api.figshare.com/v2/ 64 | Current deposits : 1 (see 'deposits' element for details) 65 | 66 | hostdata : 67 | metadata : 6 terms (see 'metadata' element for details) 68 | local_path : /tmp/Rtmp/data 69 | resources : 1 local, 0 remote 70 | 71 | # print zenodo 72 | 73 | Code 74 | print(cli) 75 | Output 76 | 77 | deposits service : zenodo 78 | sandbox: TRUE 79 | url_base : https://sandbox.zenodo.org/api/ 80 | Current deposits : 2 (see 'deposits' element for details) 81 | 82 | hostdata : 83 | metadata : 84 | 85 | --- 86 | 87 | Code 88 | cli$deposits_methods() 89 | Output 90 | List of methods for a deposits client: 91 | 92 | - deposit_add_resource 93 | - deposit_delete 94 | - deposit_delete_file 95 | - deposit_download_file 96 | - deposit_embargo 97 | - deposit_fill_metadata 98 | - deposit_new 99 | - deposit_prereserve_doi 100 | - deposit_publish 101 | - deposit_retrieve 102 | - deposit_service 103 | - deposit_update 104 | - deposit_upload_file 105 | - deposit_version 106 | - deposits_list 107 | - deposits_methods 108 | - deposits_search 109 | 110 | see `?depositsClient` for full details of all methods. 111 | 112 | --- 113 | 114 | Code 115 | print(cli) 116 | Output 117 | 118 | deposits service : zenodo 119 | sandbox: TRUE 120 | url_base : https://sandbox.zenodo.org/api/ 121 | Current deposits : 5 (see 'deposits' element for details) 122 | 123 | url_service : https://my.deposit 124 | deposit id : 1 125 | hostdata : list with 1 elements 126 | metadata : 1 terms (see 'metadata' element for details) 127 | 128 | # print zenodo with local_path 129 | 130 | Code 131 | print(cli) 132 | Output 133 | 134 | deposits service : zenodo 135 | sandbox: TRUE 136 | url_base : https://sandbox.zenodo.org/api/ 137 | Current deposits : 2 (see 'deposits' element for details) 138 | 139 | hostdata : 140 | metadata : 4 terms (see 'metadata' element for details) 141 | local_path : /tmp/Rtmp/data 142 | resources : 1 local, 0 remote 143 | 144 | -------------------------------------------------------------------------------- /tests/testthat/client-new/api/account/articles.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 21696080, 4 | "title": "Modified Title", 5 | "doi": "", 6 | "handle": "", 7 | "url": "api/articles/21696080", 8 | "published_date": null, 9 | "thumb": "", 10 | "defined_type": 3, 11 | "defined_type_name": "dataset", 12 | "group_id": null, 13 | "url_private_api": "api/articles/21696080", 14 | "url_public_api": "api/articles/21696080", 15 | "url_private_html": "https://figshare.com/account/articles/21696080", 16 | "url_public_html": "https://figshare.com/articles/dataset/_/21696080", 17 | "timeline": { 18 | 19 | }, 20 | "resource_title": null, 21 | "resource_doi": null 22 | } 23 | ] 24 | -------------------------------------------------------------------------------- /tests/testthat/fs_client/api/account/articles.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 23514972, 4 | "title": "Trace Function Parameter Types", 5 | "doi": "10.6084/m9.figshare.23514972", 6 | "handle": "", 7 | "url": "api/articles/23514972", 8 | "published_date": "2022-01-01T00:00:00Z", 9 | "thumb": "", 10 | "defined_type": 9, 11 | "defined_type_name": "software", 12 | "group_id": null, 13 | "url_private_api": "api/articles/23514972", 14 | "url_public_api": "api/articles/23514972", 15 | "url_private_html": "https://figshare.com/account/articles/23514972", 16 | "url_public_html": "https://figshare.com/articles/software/Trace_Function_Parameter_Types/23514972", 17 | "timeline": { 18 | "posted": "2022-01-01T00:00:00", 19 | "firstOnline": "2022-01-01T00:00:00" 20 | }, 21 | "resource_title": null, 22 | "resource_doi": null 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /tests/testthat/fs_create/api/account/articles.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 23514972, 4 | "title": "Trace Function Parameter Types", 5 | "doi": "10.6084/m9.figshare.23514972", 6 | "handle": "", 7 | "url": "api/articles/23514972", 8 | "published_date": "2022-01-01T00:00:00Z", 9 | "thumb": "", 10 | "defined_type": 9, 11 | "defined_type_name": "software", 12 | "group_id": null, 13 | "url_private_api": "api/articles/23514972", 14 | "url_public_api": "api/articles/23514972", 15 | "url_private_html": "https://figshare.com/account/articles/23514972", 16 | "url_public_html": "https://figshare.com/articles/software/Trace_Function_Parameter_Types/23514972", 17 | "timeline": { 18 | "posted": "2022-01-01T00:00:00", 19 | "firstOnline": "2022-01-01T00:00:00" 20 | }, 21 | "resource_title": null, 22 | "resource_doi": null 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /tests/testthat/fs_get_publ/api/account/articles.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 23522487, 4 | "title": "New Modified Title", 5 | "doi": "", 6 | "handle": "", 7 | "url": "api/articles/23522487", 8 | "published_date": null, 9 | "thumb": "", 10 | "defined_type": 3, 11 | "defined_type_name": "dataset", 12 | "group_id": null, 13 | "url_private_api": "api/articles/23522487", 14 | "url_public_api": "api/articles/23522487", 15 | "url_private_html": "https://figshare.com/account/articles/23522487", 16 | "url_public_html": "https://figshare.com/articles/dataset/_/23522487", 17 | "timeline": { 18 | 19 | }, 20 | "resource_title": null, 21 | "resource_doi": null 22 | }, 23 | { 24 | "id": 23522484, 25 | "title": "New Title", 26 | "doi": "", 27 | "handle": "", 28 | "url": "api/articles/23522484", 29 | "published_date": null, 30 | "thumb": "", 31 | "defined_type": 3, 32 | "defined_type_name": "dataset", 33 | "group_id": null, 34 | "url_private_api": "api/articles/23522484", 35 | "url_public_api": "api/articles/23522484", 36 | "url_private_html": "https://figshare.com/account/articles/23522484", 37 | "url_public_html": "https://figshare.com/articles/dataset/_/23522484", 38 | "timeline": { 39 | 40 | }, 41 | "resource_title": null, 42 | "resource_doi": null 43 | }, 44 | { 45 | "id": 23514972, 46 | "title": "Trace Function Parameter Types", 47 | "doi": "10.6084/m9.figshare.23514972", 48 | "handle": "", 49 | "url": "api/articles/23514972", 50 | "published_date": "2022-01-01T00:00:00Z", 51 | "thumb": "", 52 | "defined_type": 9, 53 | "defined_type_name": "software", 54 | "group_id": null, 55 | "url_private_api": "api/articles/23514972", 56 | "url_public_api": "api/articles/23514972", 57 | "url_private_html": "https://figshare.com/account/articles/23514972", 58 | "url_public_html": "https://figshare.com/articles/software/Trace_Function_Parameter_Types/23514972", 59 | "timeline": { 60 | "posted": "2022-01-01T00:00:00", 61 | "firstOnline": "2022-01-01T00:00:00" 62 | }, 63 | "resource_title": null, 64 | "resource_doi": null 65 | } 66 | ] 67 | -------------------------------------------------------------------------------- /tests/testthat/fs_get_publ/api/articles/23514972.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | { 4 | "upload_token": "27d26fb2-e331-42a7-b5ba-bfcc51e705c3", 5 | "upload_url": "", 6 | "status": "available", 7 | "preview_state": "preview_available", 8 | "viewer_type": "archive", 9 | "is_attached_to_public_version": true, 10 | "id": 41239080, 11 | "name": "typetracer_0.1.1.007.tar.gz", 12 | "size": 24574, 13 | "is_link_only": false, 14 | "download_url": "https://ndownloader.figshare.com/files/41239080", 15 | "supplied_md5": "a66f0e1a531035b96f854d1146b257be", 16 | "computed_md5": "a66f0e1a531035b96f854d1146b257be" 17 | } 18 | ], 19 | "resource_title": null, 20 | "resource_doi": null, 21 | "group_resource_id": null, 22 | "custom_fields": [ 23 | 24 | ], 25 | "account_id": 2986795, 26 | "authors": [ 27 | { 28 | "id": 15906815, 29 | "full_name": "Mark Padgham", 30 | "is_active": false, 31 | "url_name": "_", 32 | "orcid_id": "0000-0003-2172-5265" 33 | } 34 | ], 35 | "figshare_url": "https://figshare.com/articles/software/Trace_Function_Parameter_Types/23514972", 36 | "description": "

description<\/h2>\n

The 'R' language includes a set of defined types, but the language itself is \"absurdly dynamic\" (Turcotte & Vitek (2019) ), and lacks any way to specify which types are expected by any expression. The 'typetracer' package enables code to be traced to extract detailed information on the properties of parameters passed to 'R' functions. 'typetracer' can trace individual functions or entire packages.<\/p>\n

Version<\/h2>\n

0.1.1.007<\/p>", 37 | "funding": null, 38 | "funding_list": [ 39 | 40 | ], 41 | "version": 2, 42 | "status": "public", 43 | "size": 24574, 44 | "created_date": "2022-01-01T00:00:00Z", 45 | "modified_date": "2022-01-01T00:00:00Z", 46 | "is_public": true, 47 | "is_confidential": false, 48 | "is_metadata_record": false, 49 | "confidential_reason": "", 50 | "metadata_reason": "", 51 | "license": { 52 | "value": 3, 53 | "name": "MIT", 54 | "url": "https://opensource.org/licenses/MIT" 55 | }, 56 | "tags": [ 57 | "software", 58 | "R", 59 | "computer", 60 | "language", 61 | "parameter types" 62 | ], 63 | "categories": [ 64 | { 65 | "id": 29200, 66 | "title": "Software testing, verification and validation", 67 | "parent_id": 29176, 68 | "path": "/28798/29176/29200", 69 | "source_id": "461208", 70 | "taxonomy_id": 100 71 | }, 72 | { 73 | "id": 29203, 74 | "title": "Software engineering not elsewhere classified", 75 | "parent_id": 29176, 76 | "path": "/28798/29176/29203", 77 | "source_id": "461299", 78 | "taxonomy_id": 100 79 | } 80 | ], 81 | "references": [ 82 | 83 | ], 84 | "has_linked_file": false, 85 | "citation": "Padgham, Mark (2023). Trace Function Parameter Types. figshare. Software. https://doi.org/10.6084/m9.figshare.23514972", 86 | "related_materials": [ 87 | 88 | ], 89 | "is_embargoed": false, 90 | "embargo_date": null, 91 | "embargo_type": null, 92 | "embargo_title": "", 93 | "embargo_reason": "", 94 | "embargo_options": [ 95 | 96 | ], 97 | "id": 23514972, 98 | "title": "Trace Function Parameter Types", 99 | "doi": "10.6084/m9.figshare.23514972", 100 | "handle": "", 101 | "url": "api/articles/23514972", 102 | "published_date": "2022-01-01T00:00:00Z", 103 | "thumb": "", 104 | "defined_type": 9, 105 | "defined_type_name": "software", 106 | "group_id": null, 107 | "url_private_api": "api/articles/23514972", 108 | "url_public_api": "api/articles/23514972", 109 | "url_private_html": "https://figshare.com/account/articles/23514972", 110 | "url_public_html": "https://figshare.com/articles/software/Trace_Function_Parameter_Types/23514972", 111 | "timeline": { 112 | "posted": "2022-01-01T00:00:00", 113 | "firstOnline": "2022-01-01T00:00:00" 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /tests/testthat/fs_list/api/account/articles.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 23522487, 4 | "title": "New Modified Title", 5 | "doi": "", 6 | "handle": "", 7 | "url": "api/articles/23522487", 8 | "published_date": null, 9 | "thumb": "", 10 | "defined_type": 3, 11 | "defined_type_name": "dataset", 12 | "group_id": null, 13 | "url_private_api": "api/articles/23522487", 14 | "url_public_api": "api/articles/23522487", 15 | "url_private_html": "https://figshare.com/account/articles/23522487", 16 | "url_public_html": "https://figshare.com/articles/dataset/_/23522487", 17 | "timeline": { 18 | 19 | }, 20 | "resource_title": null, 21 | "resource_doi": null 22 | }, 23 | { 24 | "id": 23522484, 25 | "title": "New Title", 26 | "doi": "", 27 | "handle": "", 28 | "url": "api/articles/23522484", 29 | "published_date": null, 30 | "thumb": "", 31 | "defined_type": 3, 32 | "defined_type_name": "dataset", 33 | "group_id": null, 34 | "url_private_api": "api/articles/23522484", 35 | "url_public_api": "api/articles/23522484", 36 | "url_private_html": "https://figshare.com/account/articles/23522484", 37 | "url_public_html": "https://figshare.com/articles/dataset/_/23522484", 38 | "timeline": { 39 | 40 | }, 41 | "resource_title": null, 42 | "resource_doi": null 43 | }, 44 | { 45 | "id": 23514972, 46 | "title": "Trace Function Parameter Types", 47 | "doi": "10.6084/m9.figshare.23514972", 48 | "handle": "", 49 | "url": "api/articles/23514972", 50 | "published_date": "2022-01-01T00:00:00Z", 51 | "thumb": "", 52 | "defined_type": 9, 53 | "defined_type_name": "software", 54 | "group_id": null, 55 | "url_private_api": "api/articles/23514972", 56 | "url_public_api": "api/articles/23514972", 57 | "url_private_html": "https://figshare.com/account/articles/23514972", 58 | "url_public_html": "https://figshare.com/articles/software/Trace_Function_Parameter_Types/23514972", 59 | "timeline": { 60 | "posted": "2022-01-01T00:00:00", 61 | "firstOnline": "2022-01-01T00:00:00" 62 | }, 63 | "resource_title": null, 64 | "resource_doi": null 65 | } 66 | ] 67 | -------------------------------------------------------------------------------- /tests/testthat/fs_new/api/account/articles-8417b4-POST.R: -------------------------------------------------------------------------------- 1 | structure(list(method = "POST", url = "api/account/articles", 2 | status_code = 201L, headers = structure(list(date = "Thu, 15 Jun 2023 09:26:19 GMT", 3 | `content-type` = "application/json", `content-length` = "108", 4 | location = "api/articles/23522487", server = "nginx", 5 | `access-control-allow-origin` = "https://api.figshare.com", 6 | `access-control-allow-methods` = "GET, POST, PUT, DELETE, OPTIONS", 7 | `access-control-allow-headers` = "Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization", 8 | `access-control-max-age` = "3600"), class = "httr2_headers"), 9 | body = charToRaw("{\"entity_id\": 23522487, \"location\": \"api/articles/23522487\", \"warnings\": []}")), class = "httr2_response") 10 | -------------------------------------------------------------------------------- /tests/testthat/fs_new/api/account/articles.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 23522487, 4 | "title": "New Title", 5 | "doi": "", 6 | "handle": "", 7 | "url": "api/articles/23522487", 8 | "published_date": null, 9 | "thumb": "", 10 | "defined_type": 3, 11 | "defined_type_name": "dataset", 12 | "group_id": null, 13 | "url_private_api": "api/articles/23522487", 14 | "url_public_api": "api/articles/23522487", 15 | "url_private_html": "https://figshare.com/account/articles/23522487", 16 | "url_public_html": "https://figshare.com/articles/dataset/_/23522487", 17 | "timeline": { 18 | 19 | }, 20 | "resource_title": null, 21 | "resource_doi": null 22 | }, 23 | { 24 | "id": 23522484, 25 | "title": "New Title", 26 | "doi": "", 27 | "handle": "", 28 | "url": "api/articles/23522484", 29 | "published_date": null, 30 | "thumb": "", 31 | "defined_type": 3, 32 | "defined_type_name": "dataset", 33 | "group_id": null, 34 | "url_private_api": "api/articles/23522484", 35 | "url_public_api": "api/articles/23522484", 36 | "url_private_html": "https://figshare.com/account/articles/23522484", 37 | "url_public_html": "https://figshare.com/articles/dataset/_/23522484", 38 | "timeline": { 39 | 40 | }, 41 | "resource_title": null, 42 | "resource_doi": null 43 | }, 44 | { 45 | "id": 23514972, 46 | "title": "Trace Function Parameter Types", 47 | "doi": "10.6084/m9.figshare.23514972", 48 | "handle": "", 49 | "url": "api/articles/23514972", 50 | "published_date": "2022-01-01T00:00:00Z", 51 | "thumb": "", 52 | "defined_type": 9, 53 | "defined_type_name": "software", 54 | "group_id": null, 55 | "url_private_api": "api/articles/23514972", 56 | "url_public_api": "api/articles/23514972", 57 | "url_private_html": "https://figshare.com/account/articles/23514972", 58 | "url_public_html": "https://figshare.com/articles/software/Trace_Function_Parameter_Types/23514972", 59 | "timeline": { 60 | "posted": "2022-01-01T00:00:00", 61 | "firstOnline": "2022-01-01T00:00:00" 62 | }, 63 | "resource_title": null, 64 | "resource_doi": null 65 | } 66 | ] 67 | -------------------------------------------------------------------------------- /tests/testthat/fs_new/api/articles/23522487.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | 4 | ], 5 | "resource_title": null, 6 | "resource_doi": null, 7 | "group_resource_id": null, 8 | "custom_fields": [ 9 | 10 | ], 11 | "account_id": 2986795, 12 | "authors": [ 13 | { 14 | "id": 11606563, 15 | "full_name": "Mark Padgham", 16 | "is_active": true, 17 | "url_name": "Mark_Padgham", 18 | "orcid_id": "" 19 | }, 20 | { 21 | "id": 12549448, 22 | "full_name": "A. Person", 23 | "is_active": false, 24 | "url_name": "_", 25 | "orcid_id": "" 26 | }, 27 | { 28 | "id": 14827645, 29 | "full_name": "B. Person", 30 | "is_active": false, 31 | "url_name": "_", 32 | "orcid_id": "" 33 | } 34 | ], 35 | "figshare_url": "https://figshare.com/articles/dataset/_/23522487", 36 | "description": "

abstract<\/h2>\nThis is the abstract\n\n

description<\/h2>\nThis is the description\n\n

version<\/h2>\n1.0\\n\\n---start-deposits-meta---\\n{\"abstract\":\"This is the abstract\",\"creator\":[{\"name\":\"A. Person\"},{\"name\":\"B. Person\"}],\"description\":\"## description\\nThis is the description\\n\\n## version\\n1.0\",\"format\":\"dataset\",\"subject\":{\"categories\":[24418],\"keywords\":[\"beaver\",\"temperature\"]},\"title\":\"New Title\"}\\n---end-deposits-meta---\\n", 37 | "funding": null, 38 | "funding_list": [ 39 | 40 | ], 41 | "version": 0, 42 | "status": "draft", 43 | "size": 0, 44 | "created_date": "2022-01-01T00:00:00Z", 45 | "modified_date": "2022-01-01T00:00:00Z", 46 | "is_public": false, 47 | "is_confidential": false, 48 | "is_metadata_record": false, 49 | "confidential_reason": "", 50 | "metadata_reason": "", 51 | "license": { 52 | "value": 1, 53 | "name": "CC BY 4.0", 54 | "url": "https://creativecommons.org/licenses/by/4.0/" 55 | }, 56 | "tags": [ 57 | "beaver", 58 | "temperature" 59 | ], 60 | "categories": [ 61 | { 62 | "id": 24418, 63 | "title": "Animal physiological ecology", 64 | "parent_id": 24397, 65 | "path": "/24130/24397/24418", 66 | "source_id": "310907", 67 | "taxonomy_id": 100 68 | } 69 | ], 70 | "references": [ 71 | 72 | ], 73 | "has_linked_file": false, 74 | "citation": "Padgham, Mark; Person, A.; Person, B. (2023). New Title. figshare. Dataset. https://figshare.com/articles/dataset/_/23522487", 75 | "related_materials": [ 76 | 77 | ], 78 | "is_embargoed": false, 79 | "embargo_date": null, 80 | "embargo_type": null, 81 | "embargo_title": "", 82 | "embargo_reason": "", 83 | "embargo_options": [ 84 | 85 | ], 86 | "id": 23522487, 87 | "title": "New Title", 88 | "doi": "", 89 | "handle": "", 90 | "url": "api/articles/23522487", 91 | "published_date": null, 92 | "thumb": "", 93 | "defined_type": 3, 94 | "defined_type_name": "dataset", 95 | "group_id": null, 96 | "url_private_api": "api/articles/23522487", 97 | "url_public_api": "api/articles/23522487", 98 | "url_private_html": "https://figshare.com/account/articles/23522487", 99 | "url_public_html": "https://figshare.com/articles/dataset/_/23522487", 100 | "timeline": { 101 | 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /tests/testthat/fs_new2/api/account/articles-8417b4-POST.R: -------------------------------------------------------------------------------- 1 | structure(list(method = "POST", url = "api/account/articles", 2 | status_code = 201L, headers = structure(list(date = "Thu, 15 Jun 2023 09:26:17 GMT", 3 | `content-type` = "application/json", `content-length` = "108", 4 | location = "api/articles/23522484", server = "nginx", 5 | `access-control-allow-origin` = "https://api.figshare.com", 6 | `access-control-allow-methods` = "GET, POST, PUT, DELETE, OPTIONS", 7 | `access-control-allow-headers` = "Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization", 8 | `access-control-max-age` = "3600"), class = "httr2_headers"), 9 | body = charToRaw("{\"entity_id\": 23522484, \"location\": \"api/articles/23522484\", \"warnings\": []}")), class = "httr2_response") 10 | -------------------------------------------------------------------------------- /tests/testthat/fs_new2/api/account/articles.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 23522484, 4 | "title": "New Title", 5 | "doi": "", 6 | "handle": "", 7 | "url": "api/articles/23522484", 8 | "published_date": null, 9 | "thumb": "", 10 | "defined_type": 3, 11 | "defined_type_name": "dataset", 12 | "group_id": null, 13 | "url_private_api": "api/articles/23522484", 14 | "url_public_api": "api/articles/23522484", 15 | "url_private_html": "https://figshare.com/account/articles/23522484", 16 | "url_public_html": "https://figshare.com/articles/dataset/_/23522484", 17 | "timeline": { 18 | 19 | }, 20 | "resource_title": null, 21 | "resource_doi": null 22 | }, 23 | { 24 | "id": 23514972, 25 | "title": "Trace Function Parameter Types", 26 | "doi": "10.6084/m9.figshare.23514972", 27 | "handle": "", 28 | "url": "api/articles/23514972", 29 | "published_date": "2022-01-01T00:00:00Z", 30 | "thumb": "", 31 | "defined_type": 9, 32 | "defined_type_name": "software", 33 | "group_id": null, 34 | "url_private_api": "api/articles/23514972", 35 | "url_public_api": "api/articles/23514972", 36 | "url_private_html": "https://figshare.com/account/articles/23514972", 37 | "url_public_html": "https://figshare.com/articles/software/Trace_Function_Parameter_Types/23514972", 38 | "timeline": { 39 | "posted": "2022-01-01T00:00:00", 40 | "firstOnline": "2022-01-01T00:00:00" 41 | }, 42 | "resource_title": null, 43 | "resource_doi": null 44 | } 45 | ] 46 | -------------------------------------------------------------------------------- /tests/testthat/fs_new2/api/articles/23522484.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | 4 | ], 5 | "resource_title": null, 6 | "resource_doi": null, 7 | "group_resource_id": null, 8 | "custom_fields": [ 9 | 10 | ], 11 | "account_id": 2986795, 12 | "authors": [ 13 | { 14 | "id": 11606563, 15 | "full_name": "Mark Padgham", 16 | "is_active": true, 17 | "url_name": "Mark_Padgham", 18 | "orcid_id": "" 19 | }, 20 | { 21 | "id": 12549448, 22 | "full_name": "A. Person", 23 | "is_active": false, 24 | "url_name": "_", 25 | "orcid_id": "" 26 | }, 27 | { 28 | "id": 14827645, 29 | "full_name": "B. Person", 30 | "is_active": false, 31 | "url_name": "_", 32 | "orcid_id": "" 33 | } 34 | ], 35 | "figshare_url": "https://figshare.com/articles/dataset/_/23522484", 36 | "description": "

abstract<\/h2>\nThis is the abstract\n\n

description<\/h2>\nThis is the description\n\n

version<\/h2>\n1.0\\n\\n---start-deposits-meta---\\n{\"abstract\":\"This is the abstract\",\"creator\":[{\"name\":\"A. Person\"},{\"name\":\"B. Person\"}],\"description\":\"## description\\nThis is the description\\n\\n## version\\n1.0\",\"format\":\"dataset\",\"subject\":{\"categories\":[24418],\"keywords\":[\"beaver\",\"temperature\"]},\"title\":\"New Title\"}\\n---end-deposits-meta---\\n", 37 | "funding": null, 38 | "funding_list": [ 39 | 40 | ], 41 | "version": 0, 42 | "status": "draft", 43 | "size": 0, 44 | "created_date": "2022-01-01T00:00:00Z", 45 | "modified_date": "2022-01-01T00:00:00Z", 46 | "is_public": false, 47 | "is_confidential": false, 48 | "is_metadata_record": false, 49 | "confidential_reason": "", 50 | "metadata_reason": "", 51 | "license": { 52 | "value": 1, 53 | "name": "CC BY 4.0", 54 | "url": "https://creativecommons.org/licenses/by/4.0/" 55 | }, 56 | "tags": [ 57 | "beaver", 58 | "temperature" 59 | ], 60 | "categories": [ 61 | { 62 | "id": 24418, 63 | "title": "Animal physiological ecology", 64 | "parent_id": 24397, 65 | "path": "/24130/24397/24418", 66 | "source_id": "310907", 67 | "taxonomy_id": 100 68 | } 69 | ], 70 | "references": [ 71 | 72 | ], 73 | "has_linked_file": false, 74 | "citation": "Padgham, Mark; Person, A.; Person, B. (2023). New Title. figshare. Dataset. https://figshare.com/articles/dataset/_/23522484", 75 | "related_materials": [ 76 | 77 | ], 78 | "is_embargoed": false, 79 | "embargo_date": null, 80 | "embargo_type": null, 81 | "embargo_title": "", 82 | "embargo_reason": "", 83 | "embargo_options": [ 84 | 85 | ], 86 | "id": 23522484, 87 | "title": "New Title", 88 | "doi": "", 89 | "handle": "", 90 | "url": "api/articles/23522484", 91 | "published_date": null, 92 | "thumb": "", 93 | "defined_type": 3, 94 | "defined_type_name": "dataset", 95 | "group_id": null, 96 | "url_private_api": "api/articles/23522484", 97 | "url_public_api": "api/articles/23522484", 98 | "url_private_html": "https://figshare.com/account/articles/23522484", 99 | "url_public_html": "https://figshare.com/articles/dataset/_/23522484", 100 | "timeline": { 101 | 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /tests/testthat/fs_retr/api/account/articles.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 23522487, 4 | "title": "New Title", 5 | "doi": "", 6 | "handle": "", 7 | "url": "api/articles/23522487", 8 | "published_date": null, 9 | "thumb": "", 10 | "defined_type": 3, 11 | "defined_type_name": "dataset", 12 | "group_id": null, 13 | "url_private_api": "api/articles/23522487", 14 | "url_public_api": "api/articles/23522487", 15 | "url_private_html": "https://figshare.com/account/articles/23522487", 16 | "url_public_html": "https://figshare.com/articles/dataset/_/23522487", 17 | "timeline": { 18 | 19 | }, 20 | "resource_title": null, 21 | "resource_doi": null 22 | }, 23 | { 24 | "id": 23522484, 25 | "title": "New Title", 26 | "doi": "", 27 | "handle": "", 28 | "url": "api/articles/23522484", 29 | "published_date": null, 30 | "thumb": "", 31 | "defined_type": 3, 32 | "defined_type_name": "dataset", 33 | "group_id": null, 34 | "url_private_api": "api/articles/23522484", 35 | "url_public_api": "api/articles/23522484", 36 | "url_private_html": "https://figshare.com/account/articles/23522484", 37 | "url_public_html": "https://figshare.com/articles/dataset/_/23522484", 38 | "timeline": { 39 | 40 | }, 41 | "resource_title": null, 42 | "resource_doi": null 43 | }, 44 | { 45 | "id": 23514972, 46 | "title": "Trace Function Parameter Types", 47 | "doi": "10.6084/m9.figshare.23514972", 48 | "handle": "", 49 | "url": "api/articles/23514972", 50 | "published_date": "2022-01-01T00:00:00Z", 51 | "thumb": "", 52 | "defined_type": 9, 53 | "defined_type_name": "software", 54 | "group_id": null, 55 | "url_private_api": "api/articles/23514972", 56 | "url_public_api": "api/articles/23514972", 57 | "url_private_html": "https://figshare.com/account/articles/23514972", 58 | "url_public_html": "https://figshare.com/articles/software/Trace_Function_Parameter_Types/23514972", 59 | "timeline": { 60 | "posted": "2022-01-01T00:00:00", 61 | "firstOnline": "2022-01-01T00:00:00" 62 | }, 63 | "resource_title": null, 64 | "resource_doi": null 65 | } 66 | ] 67 | -------------------------------------------------------------------------------- /tests/testthat/fs_retr/api/articles/23522487.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | 4 | ], 5 | "resource_title": null, 6 | "resource_doi": null, 7 | "group_resource_id": null, 8 | "custom_fields": [ 9 | 10 | ], 11 | "account_id": 2986795, 12 | "authors": [ 13 | { 14 | "id": 11606563, 15 | "full_name": "Mark Padgham", 16 | "is_active": true, 17 | "url_name": "Mark_Padgham", 18 | "orcid_id": "" 19 | }, 20 | { 21 | "id": 12549448, 22 | "full_name": "A. Person", 23 | "is_active": false, 24 | "url_name": "_", 25 | "orcid_id": "" 26 | }, 27 | { 28 | "id": 14827645, 29 | "full_name": "B. Person", 30 | "is_active": false, 31 | "url_name": "_", 32 | "orcid_id": "" 33 | } 34 | ], 35 | "figshare_url": "https://figshare.com/articles/dataset/_/23522487", 36 | "description": "

abstract<\/h2>\nThis is the abstract\n\n

description<\/h2>\nThis is the description\n\n

version<\/h2>\n1.0\\n\\n---start-deposits-meta---\\n{\"abstract\":\"This is the abstract\",\"creator\":[{\"name\":\"A. Person\"},{\"name\":\"B. Person\"}],\"description\":\"## description\\nThis is the description\\n\\n## version\\n1.0\",\"format\":\"dataset\",\"subject\":{\"categories\":[24418],\"keywords\":[\"beaver\",\"temperature\"]},\"title\":\"New Title\"}\\n---end-deposits-meta---\\n", 37 | "funding": null, 38 | "funding_list": [ 39 | 40 | ], 41 | "version": 0, 42 | "status": "draft", 43 | "size": 0, 44 | "created_date": "2022-01-01T00:00:00Z", 45 | "modified_date": "2022-01-01T00:00:00Z", 46 | "is_public": false, 47 | "is_confidential": false, 48 | "is_metadata_record": false, 49 | "confidential_reason": "", 50 | "metadata_reason": "", 51 | "license": { 52 | "value": 1, 53 | "name": "CC BY 4.0", 54 | "url": "https://creativecommons.org/licenses/by/4.0/" 55 | }, 56 | "tags": [ 57 | "beaver", 58 | "temperature" 59 | ], 60 | "categories": [ 61 | { 62 | "id": 24418, 63 | "title": "Animal physiological ecology", 64 | "parent_id": 24397, 65 | "path": "/24130/24397/24418", 66 | "source_id": "310907", 67 | "taxonomy_id": 100 68 | } 69 | ], 70 | "references": [ 71 | 72 | ], 73 | "has_linked_file": false, 74 | "citation": "Padgham, Mark; Person, A.; Person, B. (2023). New Title. figshare. Dataset. https://figshare.com/articles/dataset/_/23522487", 75 | "related_materials": [ 76 | 77 | ], 78 | "is_embargoed": false, 79 | "embargo_date": null, 80 | "embargo_type": null, 81 | "embargo_title": "", 82 | "embargo_reason": "", 83 | "embargo_options": [ 84 | 85 | ], 86 | "id": 23522487, 87 | "title": "New Title", 88 | "doi": "", 89 | "handle": "", 90 | "url": "api/articles/23522487", 91 | "published_date": null, 92 | "thumb": "", 93 | "defined_type": 3, 94 | "defined_type_name": "dataset", 95 | "group_id": null, 96 | "url_private_api": "api/articles/23522487", 97 | "url_public_api": "api/articles/23522487", 98 | "url_private_html": "https://figshare.com/account/articles/23522487", 99 | "url_public_html": "https://figshare.com/articles/dataset/_/23522487", 100 | "timeline": { 101 | 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /tests/testthat/fs_up/api/account/articles.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 23522487, 4 | "title": "New Title", 5 | "doi": "", 6 | "handle": "", 7 | "url": "api/articles/23522487", 8 | "published_date": null, 9 | "thumb": "", 10 | "defined_type": 3, 11 | "defined_type_name": "dataset", 12 | "group_id": null, 13 | "url_private_api": "api/articles/23522487", 14 | "url_public_api": "api/articles/23522487", 15 | "url_private_html": "https://figshare.com/account/articles/23522487", 16 | "url_public_html": "https://figshare.com/articles/dataset/_/23522487", 17 | "timeline": { 18 | 19 | }, 20 | "resource_title": null, 21 | "resource_doi": null 22 | }, 23 | { 24 | "id": 23522484, 25 | "title": "New Title", 26 | "doi": "", 27 | "handle": "", 28 | "url": "api/articles/23522484", 29 | "published_date": null, 30 | "thumb": "", 31 | "defined_type": 3, 32 | "defined_type_name": "dataset", 33 | "group_id": null, 34 | "url_private_api": "api/articles/23522484", 35 | "url_public_api": "api/articles/23522484", 36 | "url_private_html": "https://figshare.com/account/articles/23522484", 37 | "url_public_html": "https://figshare.com/articles/dataset/_/23522484", 38 | "timeline": { 39 | 40 | }, 41 | "resource_title": null, 42 | "resource_doi": null 43 | }, 44 | { 45 | "id": 23514972, 46 | "title": "Trace Function Parameter Types", 47 | "doi": "10.6084/m9.figshare.23514972", 48 | "handle": "", 49 | "url": "api/articles/23514972", 50 | "published_date": "2022-01-01T00:00:00Z", 51 | "thumb": "", 52 | "defined_type": 9, 53 | "defined_type_name": "software", 54 | "group_id": null, 55 | "url_private_api": "api/articles/23514972", 56 | "url_public_api": "api/articles/23514972", 57 | "url_private_html": "https://figshare.com/account/articles/23514972", 58 | "url_public_html": "https://figshare.com/articles/software/Trace_Function_Parameter_Types/23514972", 59 | "timeline": { 60 | "posted": "2022-01-01T00:00:00", 61 | "firstOnline": "2022-01-01T00:00:00" 62 | }, 63 | "resource_title": null, 64 | "resource_doi": null 65 | } 66 | ] 67 | -------------------------------------------------------------------------------- /tests/testthat/fs_up/api/articles/23522487-54b0b5-PUT.R: -------------------------------------------------------------------------------- 1 | structure(list(method = "PUT", url = "api/articles/23522487", 2 | status_code = 205L, headers = structure(list(date = "Thu, 15 Jun 2023 09:26:26 GMT", 3 | `content-type` = "application/json", `content-length` = "85", 4 | location = "api/articles/23522487", server = "nginx", 5 | `access-control-allow-origin` = "https://api.figshare.com", 6 | `access-control-allow-methods` = "GET, POST, PUT, DELETE, OPTIONS", 7 | `access-control-allow-headers` = "Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization", 8 | `access-control-max-age` = "3600"), class = "httr2_headers"), 9 | body = charToRaw("{\"location\": \"api/articles/23522487\", \"warnings\": []}")), class = "httr2_response") 10 | -------------------------------------------------------------------------------- /tests/testthat/fs_up/api/articles/23522487.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | { 4 | "upload_token": "04b4b28d-1bb0-454b-a8f6-537a7462ad28", 5 | "upload_url": "", 6 | "status": "available", 7 | "preview_state": "preview_in_progress", 8 | "viewer_type": "", 9 | "is_attached_to_public_version": false, 10 | "id": 41251068, 11 | "name": "data.csv", 12 | "size": 625, 13 | "is_link_only": false, 14 | "download_url": "https://ndownloader.figshare.com/files/41251068", 15 | "supplied_md5": "cc624d72ede85ef061afa494d9951f6f", 16 | "computed_md5": "cc624d72ede85ef061afa494d9951f6f" 17 | } 18 | ], 19 | "resource_title": null, 20 | "resource_doi": null, 21 | "group_resource_id": null, 22 | "custom_fields": [ 23 | 24 | ], 25 | "account_id": 2986795, 26 | "authors": [ 27 | { 28 | "id": 12549448, 29 | "full_name": "A. Person", 30 | "is_active": false, 31 | "url_name": "_", 32 | "orcid_id": "" 33 | }, 34 | { 35 | "id": 14827645, 36 | "full_name": "B. Person", 37 | "is_active": false, 38 | "url_name": "_", 39 | "orcid_id": "" 40 | } 41 | ], 42 | "figshare_url": "https://figshare.com/articles/dataset/_/23522487", 43 | "description": "

abstract<\/h2>\nThis is the abstract\n\n

description<\/h2>\nThis is the description\n\n

version<\/h2>\n1.0", 44 | "funding": null, 45 | "funding_list": [ 46 | 47 | ], 48 | "version": 0, 49 | "status": "private", 50 | "size": 625, 51 | "created_date": "2022-01-01T00:00:00Z", 52 | "modified_date": "2022-01-01T00:00:00Z", 53 | "is_public": false, 54 | "is_confidential": false, 55 | "is_metadata_record": false, 56 | "confidential_reason": "", 57 | "metadata_reason": "", 58 | "license": { 59 | "value": 1, 60 | "name": "CC BY 4.0", 61 | "url": "https://creativecommons.org/licenses/by/4.0/" 62 | }, 63 | "tags": [ 64 | "beaver", 65 | "temperature" 66 | ], 67 | "categories": [ 68 | { 69 | "id": 24418, 70 | "title": "Animal physiological ecology", 71 | "parent_id": 24397, 72 | "path": "/24130/24397/24418", 73 | "source_id": "310907", 74 | "taxonomy_id": 100 75 | } 76 | ], 77 | "references": [ 78 | 79 | ], 80 | "has_linked_file": false, 81 | "citation": "Person, A.; Person, B. (2023). New Title. figshare. Dataset. https://figshare.com/articles/dataset/_/23522487", 82 | "related_materials": [ 83 | 84 | ], 85 | "is_embargoed": false, 86 | "embargo_date": null, 87 | "embargo_type": null, 88 | "embargo_title": "", 89 | "embargo_reason": "", 90 | "embargo_options": [ 91 | 92 | ], 93 | "id": 23522487, 94 | "title": "New Title", 95 | "doi": "", 96 | "handle": "", 97 | "url": "api/articles/23522487", 98 | "published_date": null, 99 | "thumb": "", 100 | "defined_type": 3, 101 | "defined_type_name": "dataset", 102 | "group_id": null, 103 | "url_private_api": "api/articles/23522487", 104 | "url_public_api": "api/articles/23522487", 105 | "url_private_html": "https://figshare.com/account/articles/23522487", 106 | "url_public_html": "https://figshare.com/articles/dataset/_/23522487", 107 | "timeline": { 108 | 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /tests/testthat/fs_up/api/articles/23522487/files-8d2582-POST.R: -------------------------------------------------------------------------------- 1 | structure(list(method = "POST", url = "api/articles/23522487/files", 2 | status_code = 201L, headers = structure(list(date = "Thu, 15 Jun 2023 09:26:24 GMT", 3 | `content-type` = "application/json", `content-length` = "84", 4 | location = "api/articles/23522487/files/41251068", server = "nginx", 5 | `access-control-allow-origin` = "https://api.figshare.com", 6 | `access-control-allow-methods` = "GET, POST, PUT, DELETE, OPTIONS", 7 | `access-control-allow-headers` = "Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization", 8 | `access-control-max-age` = "3600"), class = "httr2_headers"), 9 | body = charToRaw("{\"location\": \"api/articles/23522487/files/41251068\"}")), class = "httr2_response") 10 | -------------------------------------------------------------------------------- /tests/testthat/fs_up/api/articles/23522487/files/41251068-POST.R: -------------------------------------------------------------------------------- 1 | structure(list(method = "POST", url = "api/articles/23522487/files/41251068", 2 | status_code = 202L, headers = structure(list(date = "Thu, 15 Jun 2023 09:26:25 GMT", 3 | `content-type` = "text/html; charset=UTF-8", `content-length` = "157", 4 | location = "api/articles/23522487/files/41251068", server = "nginx", 5 | `access-control-allow-origin` = "https://api.figshare.com", 6 | `access-control-allow-methods` = "GET, POST, PUT, DELETE, OPTIONS", 7 | `access-control-allow-headers` = "Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization", 8 | `access-control-max-age` = "3600"), class = "httr2_headers"), 9 | body = charToRaw("\n \n 202 Accepted\n \n \n

202 Accepted

\n The request is accepted for processing.

\n\n\n\n \n")), class = "httr2_response") 10 | -------------------------------------------------------------------------------- /tests/testthat/fs_up/api/articles/23522487/files/41251068.json: -------------------------------------------------------------------------------- 1 | { 2 | "upload_token": "04b4b28d-1bb0-454b-a8f6-537a7462ad28", 3 | "upload_url": "https://fup-eu-west-1.up/04b4b28d-1bb0-454b-a8f6-537a7462ad28", 4 | "status": "created", 5 | "preview_state": "preview_not_available", 6 | "viewer_type": "", 7 | "is_attached_to_public_version": false, 8 | "id": 41251068, 9 | "name": "data.csv", 10 | "size": 625, 11 | "is_link_only": false, 12 | "download_url": "https://ndownloader.figshare.com/files/41251068", 13 | "supplied_md5": "cc624d72ede85ef061afa494d9951f6f", 14 | "computed_md5": "" 15 | } 16 | -------------------------------------------------------------------------------- /tests/testthat/fs_up/files/hash/1-861b94-PUT.txt: -------------------------------------------------------------------------------- 1 | OK -------------------------------------------------------------------------------- /tests/testthat/fs_up/fup-eu-west-1.up/04b4b28d-1bb0-454b-a8f6-537a7462ad28.json: -------------------------------------------------------------------------------- 1 | { 2 | "token": "04b4b28d-1bb0-454b-a8f6-537a7462ad28", 3 | "md5": "cc624d72ede85ef061afa494d9951f6f", 4 | "size": 625, 5 | "name": "41251068/data.csv", 6 | "status": "PENDING", 7 | "parts": [ 8 | { 9 | "partNo": 1, 10 | "startOffset": 0, 11 | "endOffset": 624, 12 | "status": "PENDING", 13 | "locked": false 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /tests/testthat/fs_up2/api/account/articles.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 23522487, 4 | "title": "New Title", 5 | "doi": "", 6 | "handle": "", 7 | "url": "api/articles/23522487", 8 | "published_date": null, 9 | "thumb": "", 10 | "defined_type": 3, 11 | "defined_type_name": "dataset", 12 | "group_id": null, 13 | "url_private_api": "api/articles/23522487", 14 | "url_public_api": "api/articles/23522487", 15 | "url_private_html": "https://figshare.com/account/articles/23522487", 16 | "url_public_html": "https://figshare.com/articles/dataset/_/23522487", 17 | "timeline": { 18 | 19 | }, 20 | "resource_title": null, 21 | "resource_doi": null 22 | }, 23 | { 24 | "id": 23522484, 25 | "title": "New Title", 26 | "doi": "", 27 | "handle": "", 28 | "url": "api/articles/23522484", 29 | "published_date": null, 30 | "thumb": "", 31 | "defined_type": 3, 32 | "defined_type_name": "dataset", 33 | "group_id": null, 34 | "url_private_api": "api/articles/23522484", 35 | "url_public_api": "api/articles/23522484", 36 | "url_private_html": "https://figshare.com/account/articles/23522484", 37 | "url_public_html": "https://figshare.com/articles/dataset/_/23522484", 38 | "timeline": { 39 | 40 | }, 41 | "resource_title": null, 42 | "resource_doi": null 43 | }, 44 | { 45 | "id": 23514972, 46 | "title": "Trace Function Parameter Types", 47 | "doi": "10.6084/m9.figshare.23514972", 48 | "handle": "", 49 | "url": "api/articles/23514972", 50 | "published_date": "2022-01-01T00:00:00Z", 51 | "thumb": "", 52 | "defined_type": 9, 53 | "defined_type_name": "software", 54 | "group_id": null, 55 | "url_private_api": "api/articles/23514972", 56 | "url_public_api": "api/articles/23514972", 57 | "url_private_html": "https://figshare.com/account/articles/23514972", 58 | "url_public_html": "https://figshare.com/articles/software/Trace_Function_Parameter_Types/23514972", 59 | "timeline": { 60 | "posted": "2022-01-01T00:00:00", 61 | "firstOnline": "2022-01-01T00:00:00" 62 | }, 63 | "resource_title": null, 64 | "resource_doi": null 65 | } 66 | ] 67 | -------------------------------------------------------------------------------- /tests/testthat/fs_up2/api/articles/23522487-54b0b5-PUT.R: -------------------------------------------------------------------------------- 1 | structure(list(method = "PUT", url = "api/articles/23522487", 2 | status_code = 205L, headers = structure(list(date = "Thu, 15 Jun 2023 09:26:29 GMT", 3 | `content-type` = "application/json", `content-length` = "85", 4 | location = "api/articles/23522487", server = "nginx", 5 | `access-control-allow-origin` = "https://api.figshare.com", 6 | `access-control-allow-methods` = "GET, POST, PUT, DELETE, OPTIONS", 7 | `access-control-allow-headers` = "Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization", 8 | `access-control-max-age` = "3600"), class = "httr2_headers"), 9 | body = charToRaw("{\"location\": \"api/articles/23522487\", \"warnings\": []}")), class = "httr2_response") 10 | -------------------------------------------------------------------------------- /tests/testthat/fs_up2/api/articles/23522487.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | { 4 | "upload_token": "04b4b28d-1bb0-454b-a8f6-537a7462ad28", 5 | "upload_url": "", 6 | "status": "available", 7 | "preview_state": "preview_in_progress", 8 | "viewer_type": "", 9 | "is_attached_to_public_version": false, 10 | "id": 41251068, 11 | "name": "data.csv", 12 | "size": 625, 13 | "is_link_only": false, 14 | "download_url": "https://ndownloader.figshare.com/files/41251068", 15 | "supplied_md5": "cc624d72ede85ef061afa494d9951f6f", 16 | "computed_md5": "cc624d72ede85ef061afa494d9951f6f" 17 | }, 18 | { 19 | "upload_token": "aa8d38ef-a31c-4852-b3f8-ecdebec4f6df", 20 | "upload_url": "", 21 | "status": "available", 22 | "preview_state": "preview_in_progress", 23 | "viewer_type": "", 24 | "is_attached_to_public_version": false, 25 | "id": 41251092, 26 | "name": "data2.csv", 27 | "size": 625, 28 | "is_link_only": false, 29 | "download_url": "https://ndownloader.figshare.com/files/41251092", 30 | "supplied_md5": "cc624d72ede85ef061afa494d9951f6f", 31 | "computed_md5": "cc624d72ede85ef061afa494d9951f6f" 32 | } 33 | ], 34 | "resource_title": null, 35 | "resource_doi": null, 36 | "group_resource_id": null, 37 | "custom_fields": [ 38 | 39 | ], 40 | "account_id": 2986795, 41 | "authors": [ 42 | { 43 | "id": 12549448, 44 | "full_name": "A. Person", 45 | "is_active": false, 46 | "url_name": "_", 47 | "orcid_id": "" 48 | }, 49 | { 50 | "id": 14827645, 51 | "full_name": "B. Person", 52 | "is_active": false, 53 | "url_name": "_", 54 | "orcid_id": "" 55 | } 56 | ], 57 | "figshare_url": "https://figshare.com/articles/dataset/_/23522487", 58 | "description": "

abstract<\/h2>\nThis is the abstract\n\n

description<\/h2>\nThis is the description\n\n

version<\/h2>\n1.0", 59 | "funding": null, 60 | "funding_list": [ 61 | 62 | ], 63 | "version": 0, 64 | "status": "private", 65 | "size": 1250, 66 | "created_date": "2022-01-01T00:00:00Z", 67 | "modified_date": "2022-01-01T00:00:00Z", 68 | "is_public": false, 69 | "is_confidential": false, 70 | "is_metadata_record": false, 71 | "confidential_reason": "", 72 | "metadata_reason": "", 73 | "license": { 74 | "value": 1, 75 | "name": "CC BY 4.0", 76 | "url": "https://creativecommons.org/licenses/by/4.0/" 77 | }, 78 | "tags": [ 79 | "beaver", 80 | "temperature" 81 | ], 82 | "categories": [ 83 | { 84 | "id": 24418, 85 | "title": "Animal physiological ecology", 86 | "parent_id": 24397, 87 | "path": "/24130/24397/24418", 88 | "source_id": "310907", 89 | "taxonomy_id": 100 90 | } 91 | ], 92 | "references": [ 93 | 94 | ], 95 | "has_linked_file": false, 96 | "citation": "Person, A.; Person, B. (2023). New Title. figshare. Dataset. https://figshare.com/articles/dataset/_/23522487", 97 | "related_materials": [ 98 | 99 | ], 100 | "is_embargoed": false, 101 | "embargo_date": null, 102 | "embargo_type": null, 103 | "embargo_title": "", 104 | "embargo_reason": "", 105 | "embargo_options": [ 106 | 107 | ], 108 | "id": 23522487, 109 | "title": "New Title", 110 | "doi": "", 111 | "handle": "", 112 | "url": "api/articles/23522487", 113 | "published_date": null, 114 | "thumb": "", 115 | "defined_type": 3, 116 | "defined_type_name": "dataset", 117 | "group_id": null, 118 | "url_private_api": "api/articles/23522487", 119 | "url_public_api": "api/articles/23522487", 120 | "url_private_html": "https://figshare.com/account/articles/23522487", 121 | "url_public_html": "https://figshare.com/articles/dataset/_/23522487", 122 | "timeline": { 123 | 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /tests/testthat/fs_up2/api/articles/23522487/files-e3c461-POST.R: -------------------------------------------------------------------------------- 1 | structure(list(method = "POST", url = "api/articles/23522487/files", 2 | status_code = 201L, headers = structure(list(date = "Thu, 15 Jun 2023 09:26:27 GMT", 3 | `content-type` = "application/json", `content-length` = "84", 4 | location = "api/articles/23522487/files/41251092", server = "nginx", 5 | `access-control-allow-origin` = "https://api.figshare.com", 6 | `access-control-allow-methods` = "GET, POST, PUT, DELETE, OPTIONS", 7 | `access-control-allow-headers` = "Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization", 8 | `access-control-max-age` = "3600"), class = "httr2_headers"), 9 | body = charToRaw("{\"location\": \"api/articles/23522487/files/41251092\"}")), class = "httr2_response") 10 | -------------------------------------------------------------------------------- /tests/testthat/fs_up2/api/articles/23522487/files/41251092-POST.R: -------------------------------------------------------------------------------- 1 | structure(list(method = "POST", url = "api/articles/23522487/files/41251092", 2 | status_code = 202L, headers = structure(list(date = "Thu, 15 Jun 2023 09:26:28 GMT", 3 | `content-type` = "text/html; charset=UTF-8", `content-length` = "157", 4 | location = "api/articles/23522487/files/41251092", server = "nginx", 5 | `access-control-allow-origin` = "https://api.figshare.com", 6 | `access-control-allow-methods` = "GET, POST, PUT, DELETE, OPTIONS", 7 | `access-control-allow-headers` = "Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization", 8 | `access-control-max-age` = "3600"), class = "httr2_headers"), 9 | body = charToRaw("\n \n 202 Accepted\n \n \n

202 Accepted

\n The request is accepted for processing.

\n\n\n\n \n")), class = "httr2_response") 10 | -------------------------------------------------------------------------------- /tests/testthat/fs_up2/api/articles/23522487/files/41251092.json: -------------------------------------------------------------------------------- 1 | { 2 | "upload_token": "aa8d38ef-a31c-4852-b3f8-ecdebec4f6df", 3 | "upload_url": "https://fup-eu-west-1.up/aa8d38ef-a31c-4852-b3f8-ecdebec4f6df", 4 | "status": "created", 5 | "preview_state": "preview_not_available", 6 | "viewer_type": "", 7 | "is_attached_to_public_version": false, 8 | "id": 41251092, 9 | "name": "data2.csv", 10 | "size": 625, 11 | "is_link_only": false, 12 | "download_url": "https://ndownloader.figshare.com/files/41251092", 13 | "supplied_md5": "cc624d72ede85ef061afa494d9951f6f", 14 | "computed_md5": "" 15 | } 16 | -------------------------------------------------------------------------------- /tests/testthat/fs_up2/files/hash/1-861b94-PUT.txt: -------------------------------------------------------------------------------- 1 | OK -------------------------------------------------------------------------------- /tests/testthat/fs_up2/fup-eu-west-1.up/aa8d38ef-a31c-4852-b3f8-ecdebec4f6df.json: -------------------------------------------------------------------------------- 1 | { 2 | "token": "aa8d38ef-a31c-4852-b3f8-ecdebec4f6df", 3 | "md5": "cc624d72ede85ef061afa494d9951f6f", 4 | "size": 625, 5 | "name": "41251092/data2.csv", 6 | "status": "PENDING", 7 | "parts": [ 8 | { 9 | "partNo": 1, 10 | "startOffset": 0, 11 | "endOffset": 624, 12 | "status": "PENDING", 13 | "locked": false 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /tests/testthat/fs_update/api/account/articles.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 23522487, 4 | "title": "Modified Title", 5 | "doi": "", 6 | "handle": "", 7 | "url": "api/articles/23522487", 8 | "published_date": null, 9 | "thumb": "", 10 | "defined_type": 3, 11 | "defined_type_name": "dataset", 12 | "group_id": null, 13 | "url_private_api": "api/articles/23522487", 14 | "url_public_api": "api/articles/23522487", 15 | "url_private_html": "https://figshare.com/account/articles/23522487", 16 | "url_public_html": "https://figshare.com/articles/dataset/_/23522487", 17 | "timeline": { 18 | 19 | }, 20 | "resource_title": null, 21 | "resource_doi": null 22 | }, 23 | { 24 | "id": 23522484, 25 | "title": "New Title", 26 | "doi": "", 27 | "handle": "", 28 | "url": "api/articles/23522484", 29 | "published_date": null, 30 | "thumb": "", 31 | "defined_type": 3, 32 | "defined_type_name": "dataset", 33 | "group_id": null, 34 | "url_private_api": "api/articles/23522484", 35 | "url_public_api": "api/articles/23522484", 36 | "url_private_html": "https://figshare.com/account/articles/23522484", 37 | "url_public_html": "https://figshare.com/articles/dataset/_/23522484", 38 | "timeline": { 39 | 40 | }, 41 | "resource_title": null, 42 | "resource_doi": null 43 | }, 44 | { 45 | "id": 23514972, 46 | "title": "Trace Function Parameter Types", 47 | "doi": "10.6084/m9.figshare.23514972", 48 | "handle": "", 49 | "url": "api/articles/23514972", 50 | "published_date": "2022-01-01T00:00:00Z", 51 | "thumb": "", 52 | "defined_type": 9, 53 | "defined_type_name": "software", 54 | "group_id": null, 55 | "url_private_api": "api/articles/23514972", 56 | "url_public_api": "api/articles/23514972", 57 | "url_private_html": "https://figshare.com/account/articles/23514972", 58 | "url_public_html": "https://figshare.com/articles/software/Trace_Function_Parameter_Types/23514972", 59 | "timeline": { 60 | "posted": "2022-01-01T00:00:00", 61 | "firstOnline": "2022-01-01T00:00:00" 62 | }, 63 | "resource_title": null, 64 | "resource_doi": null 65 | } 66 | ] 67 | -------------------------------------------------------------------------------- /tests/testthat/fs_update/api/articles/23522487-c14ad9-PUT.R: -------------------------------------------------------------------------------- 1 | structure(list(method = "PUT", url = "api/articles/23522487", 2 | status_code = 205L, headers = structure(list(date = "Thu, 15 Jun 2023 09:26:21 GMT", 3 | `content-type` = "application/json", `content-length` = "85", 4 | location = "api/articles/23522487", server = "nginx", 5 | `access-control-allow-origin` = "https://api.figshare.com", 6 | `access-control-allow-methods` = "GET, POST, PUT, DELETE, OPTIONS", 7 | `access-control-allow-headers` = "Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization", 8 | `access-control-max-age` = "3600"), class = "httr2_headers"), 9 | body = charToRaw("{\"location\": \"api/articles/23522487\", \"warnings\": []}")), class = "httr2_response") 10 | -------------------------------------------------------------------------------- /tests/testthat/fs_update/api/articles/23522487.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | 4 | ], 5 | "resource_title": null, 6 | "resource_doi": null, 7 | "group_resource_id": null, 8 | "custom_fields": [ 9 | 10 | ], 11 | "account_id": 2986795, 12 | "authors": [ 13 | { 14 | "id": 12574198, 15 | "full_name": "C. Person", 16 | "is_active": false, 17 | "url_name": "_", 18 | "orcid_id": "" 19 | } 20 | ], 21 | "figshare_url": "https://figshare.com/articles/dataset/_/23522487", 22 | "description": "

abstract<\/h2>\nThis is the modified abstract\n\n

description<\/h2>\nThis is the description\n\n

version<\/h2>\n1.0", 23 | "funding": null, 24 | "funding_list": [ 25 | 26 | ], 27 | "version": 0, 28 | "status": "private", 29 | "size": 0, 30 | "created_date": "2022-01-01T00:00:00Z", 31 | "modified_date": "2022-01-01T00:00:00Z", 32 | "is_public": false, 33 | "is_confidential": false, 34 | "is_metadata_record": false, 35 | "confidential_reason": "", 36 | "metadata_reason": "", 37 | "license": { 38 | "value": 1, 39 | "name": "CC BY 4.0", 40 | "url": "https://creativecommons.org/licenses/by/4.0/" 41 | }, 42 | "tags": [ 43 | "beaver", 44 | "temperature" 45 | ], 46 | "categories": [ 47 | { 48 | "id": 24418, 49 | "title": "Animal physiological ecology", 50 | "parent_id": 24397, 51 | "path": "/24130/24397/24418", 52 | "source_id": "310907", 53 | "taxonomy_id": 100 54 | } 55 | ], 56 | "references": [ 57 | 58 | ], 59 | "has_linked_file": false, 60 | "citation": "Person, C. (2023). Modified Title. figshare. Dataset. https://figshare.com/articles/dataset/_/23522487", 61 | "related_materials": [ 62 | 63 | ], 64 | "is_embargoed": false, 65 | "embargo_date": null, 66 | "embargo_type": null, 67 | "embargo_title": "", 68 | "embargo_reason": "", 69 | "embargo_options": [ 70 | 71 | ], 72 | "id": 23522487, 73 | "title": "Modified Title", 74 | "doi": "", 75 | "handle": "", 76 | "url": "api/articles/23522487", 77 | "published_date": null, 78 | "thumb": "", 79 | "defined_type": 3, 80 | "defined_type_name": "dataset", 81 | "group_id": null, 82 | "url_private_api": "api/articles/23522487", 83 | "url_public_api": "api/articles/23522487", 84 | "url_private_html": "https://figshare.com/account/articles/23522487", 85 | "url_public_html": "https://figshare.com/articles/dataset/_/23522487", 86 | "timeline": { 87 | 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /tests/testthat/fs_update_dp1/api/articles/23522487-54b0b5-PUT.R: -------------------------------------------------------------------------------- 1 | structure(list(method = "PUT", url = "api/articles/23522487", 2 | status_code = 205L, headers = structure(list(date = "Thu, 15 Jun 2023 09:26:32 GMT", 3 | `content-type` = "application/json", `content-length` = "85", 4 | location = "api/articles/23522487", server = "nginx", 5 | `access-control-allow-origin` = "https://api.figshare.com", 6 | `access-control-allow-methods` = "GET, POST, PUT, DELETE, OPTIONS", 7 | `access-control-allow-headers` = "Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization", 8 | `access-control-max-age` = "3600"), class = "httr2_headers"), 9 | body = charToRaw("{\"location\": \"api/articles/23522487\", \"warnings\": []}")), class = "httr2_response") 10 | -------------------------------------------------------------------------------- /tests/testthat/fs_update_dp2/api/articles/23522487-1e2e5c-PUT.R: -------------------------------------------------------------------------------- 1 | structure(list(method = "PUT", url = "api/articles/23522487", 2 | status_code = 205L, headers = structure(list(date = "Thu, 15 Jun 2023 09:26:32 GMT", 3 | `content-type` = "application/json", `content-length` = "85", 4 | location = "api/articles/23522487", server = "nginx", 5 | `access-control-allow-origin` = "https://api.figshare.com", 6 | `access-control-allow-methods` = "GET, POST, PUT, DELETE, OPTIONS", 7 | `access-control-allow-headers` = "Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization", 8 | `access-control-max-age` = "3600"), class = "httr2_headers"), 9 | body = charToRaw("{\"location\": \"api/articles/23522487\", \"warnings\": []}")), class = "httr2_response") 10 | -------------------------------------------------------------------------------- /tests/testthat/helper-test-client.R: -------------------------------------------------------------------------------- 1 | # Function to construct single mock deposit 2 | new_mock_deposit <- function (service = "zenodo") { 3 | 4 | metadata <- list ( 5 | title = "New Title", 6 | abstract = "This is the abstract", 7 | creator = list (list (name = "A. Person"), list (name = "B. Person")), 8 | description = 9 | "## description\nThis is the description\n\n## version\n1.0", 10 | subject = "## keywords\none, two\nthree" 11 | ) 12 | 13 | if (service == "figshare") { 14 | metadata$subject <- list ( 15 | categories = list (24418L), 16 | keywords = as.list (c ("beaver", "temperature")) 17 | ) 18 | metadata$format <- "dataset" 19 | } else if (service == "zenodo") { 20 | metadata$accessRights <- "closed" 21 | } 22 | 23 | prfx <- ifelse (service == "zenodo", "zen", "fs") 24 | 25 | cli <- httptest2::with_mock_dir (paste0 (prfx, "_client"), { 26 | depositsClient$new ( 27 | service = service, 28 | sandbox = TRUE, 29 | metadata = metadata 30 | ) 31 | }) 32 | cli <- httptest2::with_mock_dir (paste0 (prfx, "_new"), { 33 | cli$deposit_new (prereserve_doi = TRUE) 34 | }) 35 | 36 | return (cli) 37 | } 38 | -------------------------------------------------------------------------------- /tests/testthat/meta-new1/sbapi/deposit/depositions-fa7f86.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "conceptrecid": "1134664", 4 | "created": "2022-01-01T00:00:00", 5 | "doi": "", 6 | "doi_url": "https://doi.org/", 7 | "id": 1134665, 8 | "links": { 9 | "discard": "sbapi/deposit/depositions/1134665/actions/discard", 10 | "edit": "sbapi/deposit/depositions/1134665/actions/edit", 11 | "files": "sbapi/deposit/depositions/1134665/files", 12 | "html": "https://sandbox.zenodo.org/deposit/1134665", 13 | "latest_draft": "sbapi/deposit/depositions/1134665", 14 | "latest_draft_html": "https://sandbox.zenodo.org/deposit/1134665", 15 | "publish": "sbapi/deposit/depositions/1134665/actions/publish", 16 | "self": "sbapi/deposit/depositions/1134665" 17 | }, 18 | "metadata": { 19 | "access_right": "open", 20 | "creators": [ 21 | { 22 | "name": "C. Person" 23 | } 24 | ], 25 | "description": "This is the modified abstract", 26 | "doi": "", 27 | "license": "CC-BY-4.0", 28 | "prereserve_doi": { 29 | "doi": "10.5072/zenodo.1134665", 30 | "recid": 1134665 31 | }, 32 | "publication_date": "2022-01-01", 33 | "title": "Modified Title", 34 | "upload_type": "other" 35 | }, 36 | "modified": "2022-01-01T00:00:00", 37 | "owner": 115518, 38 | "record_id": 1134665, 39 | "state": "unsubmitted", 40 | "submitted": false, 41 | "title": "Modified Title" 42 | }, 43 | { 44 | "conceptdoi": "10.5072/zenodo.1077311", 45 | "conceptrecid": "1077311", 46 | "created": "2022-01-01T00:00:00", 47 | "doi": "10.5072/zenodo.1077312", 48 | "doi_url": "https://doi.org/10.5072/zenodo.1077312", 49 | "files": [ 50 | { 51 | "checksum": "3b6fd6ea9689be256621fb7fcc3cd81f", 52 | "filename": "DCEntry-1077312.xml", 53 | "filesize": 829, 54 | "id": "2b44d9ce-bf3f-45b1-8c59-dd24bcda6018", 55 | "links": { 56 | "download": "sbapi/files/hash/DCEntry-1077312.xml", 57 | "self": "sbapi/deposit/depositions/1077312/files/2b44d9ce-bf3f-45b1-8c59-dd24bcda6018" 58 | } 59 | }, 60 | { 61 | "checksum": "2f66f32c95d5ff3ccd3ddd1cadc797b0", 62 | "filename": "RJwrapper.pdf", 63 | "filesize": 36414, 64 | "id": "cdc0fa50-4582-4830-a6b7-63999ce736c4", 65 | "links": { 66 | "download": "sbapi/files/hash/RJwrapper.pdf", 67 | "self": "sbapi/deposit/depositions/1077312/files/cdc0fa50-4582-4830-a6b7-63999ce736c4" 68 | } 69 | } 70 | ], 71 | "id": 1077312, 72 | "links": { 73 | "badge": "https://sandbox.zenodo.org/badge/doi/10.5072/zenodo.1077312.svg", 74 | "bucket": "sbapi/files/57f59a19-a514-4e97-9273-85a65bdd267e", 75 | "conceptbadge": "https://sandbox.zenodo.org/badge/doi/10.5072/zenodo.1077311.svg", 76 | "conceptdoi": "https://doi.org/10.5072/zenodo.1077311", 77 | "discard": "sbapi/deposit/depositions/1077312/actions/discard", 78 | "doi": "https://doi.org/10.5072/zenodo.1077312", 79 | "edit": "sbapi/deposit/depositions/1077312/actions/edit", 80 | "files": "sbapi/deposit/depositions/1077312/files", 81 | "html": "https://sandbox.zenodo.org/deposit/1077312", 82 | "latest": "sbapi/records/1077312", 83 | "latest_html": "https://sandbox.zenodo.org/record/1077312", 84 | "publish": "sbapi/deposit/depositions/1077312/actions/publish", 85 | "record": "sbapi/records/1077312", 86 | "record_html": "https://sandbox.zenodo.org/record/1077312", 87 | "self": "sbapi/deposit/depositions/1077312" 88 | }, 89 | "metadata": { 90 | "access_right": "closed", 91 | "communities": [ 92 | { 93 | "identifier": "zenodo" 94 | } 95 | ], 96 | "creators": [ 97 | { 98 | "name": "A. Person,B. Person" 99 | } 100 | ], 101 | "description": "

This is the abstract<\/p>", 102 | "doi": "10.5072/zenodo.1077312", 103 | "prereserve_doi": { 104 | "doi": "10.5072/zenodo.1077312", 105 | "recid": 1077312 106 | }, 107 | "publication_date": "2022-01-01", 108 | "title": "New Title", 109 | "upload_type": "other" 110 | }, 111 | "modified": "2022-01-01T00:00:00", 112 | "owner": 115518, 113 | "record_id": 1077312, 114 | "state": "inprogress", 115 | "submitted": true, 116 | "title": "New Title" 117 | } 118 | ] 119 | -------------------------------------------------------------------------------- /tests/testthat/meta-new2/sbapi/deposit/depositions-fa7f86.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "conceptrecid": "1134664", 4 | "created": "2022-01-01T00:00:00", 5 | "doi": "", 6 | "doi_url": "https://doi.org/", 7 | "id": 1134665, 8 | "links": { 9 | "discard": "sbapi/deposit/depositions/1134665/actions/discard", 10 | "edit": "sbapi/deposit/depositions/1134665/actions/edit", 11 | "files": "sbapi/deposit/depositions/1134665/files", 12 | "html": "https://sandbox.zenodo.org/deposit/1134665", 13 | "latest_draft": "sbapi/deposit/depositions/1134665", 14 | "latest_draft_html": "https://sandbox.zenodo.org/deposit/1134665", 15 | "publish": "sbapi/deposit/depositions/1134665/actions/publish", 16 | "self": "sbapi/deposit/depositions/1134665" 17 | }, 18 | "metadata": { 19 | "access_right": "open", 20 | "creators": [ 21 | { 22 | "name": "C. Person" 23 | } 24 | ], 25 | "description": "This is the modified abstract", 26 | "doi": "", 27 | "license": "CC-BY-4.0", 28 | "prereserve_doi": { 29 | "doi": "10.5072/zenodo.1134665", 30 | "recid": 1134665 31 | }, 32 | "publication_date": "2022-01-01", 33 | "title": "Modified Title", 34 | "upload_type": "other" 35 | }, 36 | "modified": "2022-01-01T00:00:00", 37 | "owner": 115518, 38 | "record_id": 1134665, 39 | "state": "unsubmitted", 40 | "submitted": false, 41 | "title": "Modified Title" 42 | }, 43 | { 44 | "conceptdoi": "10.5072/zenodo.1077311", 45 | "conceptrecid": "1077311", 46 | "created": "2022-01-01T00:00:00", 47 | "doi": "10.5072/zenodo.1077312", 48 | "doi_url": "https://doi.org/10.5072/zenodo.1077312", 49 | "files": [ 50 | { 51 | "checksum": "3b6fd6ea9689be256621fb7fcc3cd81f", 52 | "filename": "DCEntry-1077312.xml", 53 | "filesize": 829, 54 | "id": "2b44d9ce-bf3f-45b1-8c59-dd24bcda6018", 55 | "links": { 56 | "download": "sbapi/files/hash/DCEntry-1077312.xml", 57 | "self": "sbapi/deposit/depositions/1077312/files/2b44d9ce-bf3f-45b1-8c59-dd24bcda6018" 58 | } 59 | }, 60 | { 61 | "checksum": "2f66f32c95d5ff3ccd3ddd1cadc797b0", 62 | "filename": "RJwrapper.pdf", 63 | "filesize": 36414, 64 | "id": "cdc0fa50-4582-4830-a6b7-63999ce736c4", 65 | "links": { 66 | "download": "sbapi/files/hash/RJwrapper.pdf", 67 | "self": "sbapi/deposit/depositions/1077312/files/cdc0fa50-4582-4830-a6b7-63999ce736c4" 68 | } 69 | } 70 | ], 71 | "id": 1077312, 72 | "links": { 73 | "badge": "https://sandbox.zenodo.org/badge/doi/10.5072/zenodo.1077312.svg", 74 | "bucket": "sbapi/files/57f59a19-a514-4e97-9273-85a65bdd267e", 75 | "conceptbadge": "https://sandbox.zenodo.org/badge/doi/10.5072/zenodo.1077311.svg", 76 | "conceptdoi": "https://doi.org/10.5072/zenodo.1077311", 77 | "discard": "sbapi/deposit/depositions/1077312/actions/discard", 78 | "doi": "https://doi.org/10.5072/zenodo.1077312", 79 | "edit": "sbapi/deposit/depositions/1077312/actions/edit", 80 | "files": "sbapi/deposit/depositions/1077312/files", 81 | "html": "https://sandbox.zenodo.org/deposit/1077312", 82 | "latest": "sbapi/records/1077312", 83 | "latest_html": "https://sandbox.zenodo.org/record/1077312", 84 | "publish": "sbapi/deposit/depositions/1077312/actions/publish", 85 | "record": "sbapi/records/1077312", 86 | "record_html": "https://sandbox.zenodo.org/record/1077312", 87 | "self": "sbapi/deposit/depositions/1077312" 88 | }, 89 | "metadata": { 90 | "access_right": "closed", 91 | "communities": [ 92 | { 93 | "identifier": "zenodo" 94 | } 95 | ], 96 | "creators": [ 97 | { 98 | "name": "A. Person,B. Person" 99 | } 100 | ], 101 | "description": "

This is the abstract<\/p>", 102 | "doi": "10.5072/zenodo.1077312", 103 | "prereserve_doi": { 104 | "doi": "10.5072/zenodo.1077312", 105 | "recid": 1077312 106 | }, 107 | "publication_date": "2022-01-01", 108 | "title": "New Title", 109 | "upload_type": "other" 110 | }, 111 | "modified": "2022-01-01T00:00:00", 112 | "owner": 115518, 113 | "record_id": 1077312, 114 | "state": "inprogress", 115 | "submitted": true, 116 | "title": "New Title" 117 | } 118 | ] 119 | -------------------------------------------------------------------------------- /tests/testthat/meta-new3/sbapi/deposit/depositions-fa7f86.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "conceptrecid": "1134664", 4 | "created": "2022-01-01T00:00:00", 5 | "doi": "", 6 | "doi_url": "https://doi.org/", 7 | "id": 1134665, 8 | "links": { 9 | "discard": "sbapi/deposit/depositions/1134665/actions/discard", 10 | "edit": "sbapi/deposit/depositions/1134665/actions/edit", 11 | "files": "sbapi/deposit/depositions/1134665/files", 12 | "html": "https://sandbox.zenodo.org/deposit/1134665", 13 | "latest_draft": "sbapi/deposit/depositions/1134665", 14 | "latest_draft_html": "https://sandbox.zenodo.org/deposit/1134665", 15 | "publish": "sbapi/deposit/depositions/1134665/actions/publish", 16 | "self": "sbapi/deposit/depositions/1134665" 17 | }, 18 | "metadata": { 19 | "access_right": "open", 20 | "creators": [ 21 | { 22 | "name": "C. Person" 23 | } 24 | ], 25 | "description": "This is the modified abstract", 26 | "doi": "", 27 | "license": "CC-BY-4.0", 28 | "prereserve_doi": { 29 | "doi": "10.5072/zenodo.1134665", 30 | "recid": 1134665 31 | }, 32 | "publication_date": "2022-01-01", 33 | "title": "Modified Title", 34 | "upload_type": "other" 35 | }, 36 | "modified": "2022-01-01T00:00:00", 37 | "owner": 115518, 38 | "record_id": 1134665, 39 | "state": "unsubmitted", 40 | "submitted": false, 41 | "title": "Modified Title" 42 | }, 43 | { 44 | "conceptdoi": "10.5072/zenodo.1077311", 45 | "conceptrecid": "1077311", 46 | "created": "2022-01-01T00:00:00", 47 | "doi": "10.5072/zenodo.1077312", 48 | "doi_url": "https://doi.org/10.5072/zenodo.1077312", 49 | "files": [ 50 | { 51 | "checksum": "3b6fd6ea9689be256621fb7fcc3cd81f", 52 | "filename": "DCEntry-1077312.xml", 53 | "filesize": 829, 54 | "id": "2b44d9ce-bf3f-45b1-8c59-dd24bcda6018", 55 | "links": { 56 | "download": "sbapi/files/hash/DCEntry-1077312.xml", 57 | "self": "sbapi/deposit/depositions/1077312/files/2b44d9ce-bf3f-45b1-8c59-dd24bcda6018" 58 | } 59 | }, 60 | { 61 | "checksum": "2f66f32c95d5ff3ccd3ddd1cadc797b0", 62 | "filename": "RJwrapper.pdf", 63 | "filesize": 36414, 64 | "id": "cdc0fa50-4582-4830-a6b7-63999ce736c4", 65 | "links": { 66 | "download": "sbapi/files/hash/RJwrapper.pdf", 67 | "self": "sbapi/deposit/depositions/1077312/files/cdc0fa50-4582-4830-a6b7-63999ce736c4" 68 | } 69 | } 70 | ], 71 | "id": 1077312, 72 | "links": { 73 | "badge": "https://sandbox.zenodo.org/badge/doi/10.5072/zenodo.1077312.svg", 74 | "bucket": "sbapi/files/57f59a19-a514-4e97-9273-85a65bdd267e", 75 | "conceptbadge": "https://sandbox.zenodo.org/badge/doi/10.5072/zenodo.1077311.svg", 76 | "conceptdoi": "https://doi.org/10.5072/zenodo.1077311", 77 | "discard": "sbapi/deposit/depositions/1077312/actions/discard", 78 | "doi": "https://doi.org/10.5072/zenodo.1077312", 79 | "edit": "sbapi/deposit/depositions/1077312/actions/edit", 80 | "files": "sbapi/deposit/depositions/1077312/files", 81 | "html": "https://sandbox.zenodo.org/deposit/1077312", 82 | "latest": "sbapi/records/1077312", 83 | "latest_html": "https://sandbox.zenodo.org/record/1077312", 84 | "publish": "sbapi/deposit/depositions/1077312/actions/publish", 85 | "record": "sbapi/records/1077312", 86 | "record_html": "https://sandbox.zenodo.org/record/1077312", 87 | "self": "sbapi/deposit/depositions/1077312" 88 | }, 89 | "metadata": { 90 | "access_right": "closed", 91 | "communities": [ 92 | { 93 | "identifier": "zenodo" 94 | } 95 | ], 96 | "creators": [ 97 | { 98 | "name": "A. Person,B. Person" 99 | } 100 | ], 101 | "description": "

This is the abstract<\/p>", 102 | "doi": "10.5072/zenodo.1077312", 103 | "prereserve_doi": { 104 | "doi": "10.5072/zenodo.1077312", 105 | "recid": 1077312 106 | }, 107 | "publication_date": "2022-01-01", 108 | "title": "New Title", 109 | "upload_type": "other" 110 | }, 111 | "modified": "2022-01-01T00:00:00", 112 | "owner": 115518, 113 | "record_id": 1077312, 114 | "state": "inprogress", 115 | "submitted": true, 116 | "title": "New Title" 117 | } 118 | ] 119 | -------------------------------------------------------------------------------- /tests/testthat/print-fs/api/account/articles.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 21696080, 4 | "title": "Modified Title", 5 | "doi": "", 6 | "handle": "", 7 | "url": "api/articles/21696080", 8 | "published_date": null, 9 | "thumb": "", 10 | "defined_type": 3, 11 | "defined_type_name": "dataset", 12 | "group_id": null, 13 | "url_private_api": "api/articles/21696080", 14 | "url_public_api": "api/articles/21696080", 15 | "url_private_html": "https://figshare.com/account/articles/21696080", 16 | "url_public_html": "https://figshare.com/articles/dataset/_/21696080", 17 | "timeline": { 18 | 19 | }, 20 | "resource_title": null, 21 | "resource_doi": null 22 | } 23 | ] 24 | -------------------------------------------------------------------------------- /tests/testthat/search_fs/api/articles/search-b2e6ce-POST.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "project_id": 132974, 4 | "id": 19199774, 5 | "title": "SuppMaterial", 6 | "doi": "10.6084/m9.figshare.19199774.v1", 7 | "handle": "", 8 | "url": "api/articles/19199774", 9 | "published_date": "2022-01-01T00:00:00Z", 10 | "thumb": "https://s3-eu-west-1.amazonaws.com/pfigshare-u-previews/35316127/thumb.png", 11 | "defined_type": 11, 12 | "defined_type_name": "online resource", 13 | "group_id": null, 14 | "url_private_api": "api/articles/19199774", 15 | "url_public_api": "api/articles/19199774", 16 | "url_private_html": "https://figshare.com/account/articles/19199774", 17 | "url_public_html": "https://figshare.com/articles/online_resource/SuppMaterial/19199774", 18 | "timeline": { 19 | "posted": "2022-01-01T00:00:00", 20 | "firstOnline": "2022-01-01T00:00:00" 21 | }, 22 | "resource_title": "", 23 | "resource_doi": "" 24 | }, 25 | { 26 | "project_id": 130610, 27 | "id": 19882087, 28 | "title": "Files appendix", 29 | "doi": "10.6084/m9.figshare.19882087.v1", 30 | "handle": "", 31 | "url": "api/articles/19882087", 32 | "published_date": "2022-01-01T00:00:00Z", 33 | "thumb": "", 34 | "defined_type": 11, 35 | "defined_type_name": "online resource", 36 | "group_id": null, 37 | "url_private_api": "api/articles/19882087", 38 | "url_public_api": "api/articles/19882087", 39 | "url_private_html": "https://figshare.com/account/articles/19882087", 40 | "url_public_html": "https://figshare.com/articles/online_resource/Files_appendix/19882087", 41 | "timeline": { 42 | "posted": "2022-01-01T00:00:00", 43 | "firstOnline": "2022-01-01T00:00:00" 44 | }, 45 | "resource_title": "", 46 | "resource_doi": "" 47 | }, 48 | { 49 | "project_id": null, 50 | "id": 5845593, 51 | "title": "random.xlsx", 52 | "doi": "10.6084/m9.figshare.5845593.v1", 53 | "handle": "", 54 | "url": "api/articles/5845593", 55 | "published_date": "2022-01-01T00:00:00Z", 56 | "thumb": "", 57 | "defined_type": 3, 58 | "defined_type_name": "dataset", 59 | "group_id": null, 60 | "url_private_api": "api/articles/5845593", 61 | "url_public_api": "api/articles/5845593", 62 | "url_private_html": "https://figshare.com/account/articles/5845593", 63 | "url_public_html": "https://figshare.com/articles/dataset/random_xlsx/5845593", 64 | "timeline": { 65 | "posted": "2022-01-01T00:00:00", 66 | "firstOnline": "2022-01-01T00:00:00" 67 | }, 68 | "resource_title": "", 69 | "resource_doi": "" 70 | }, 71 | { 72 | "project_id": null, 73 | "id": 14675409, 74 | "title": "random numbers.json", 75 | "doi": "10.6084/m9.figshare.14675409.v1", 76 | "handle": "", 77 | "url": "api/articles/14675409", 78 | "published_date": "2022-01-01T00:00:00Z", 79 | "thumb": "", 80 | "defined_type": 3, 81 | "defined_type_name": "dataset", 82 | "group_id": null, 83 | "url_private_api": "api/articles/14675409", 84 | "url_public_api": "api/articles/14675409", 85 | "url_private_html": "https://figshare.com/account/articles/14675409", 86 | "url_public_html": "https://figshare.com/articles/dataset/random_numbers_json/14675409", 87 | "timeline": { 88 | "posted": "2022-01-01T00:00:00", 89 | "firstOnline": "2022-01-01T00:00:00" 90 | }, 91 | "resource_title": "", 92 | "resource_doi": "" 93 | }, 94 | { 95 | "project_id": null, 96 | "id": 12674225, 97 | "title": "Random periodic processes, periodic measures and ergodicity", 98 | "doi": "", 99 | "handle": "2134/12674225.v1", 100 | "url": "api/articles/12674225", 101 | "published_date": "2022-01-01T00:00:00Z", 102 | "thumb": "https://s3-eu-west-1.amazonaws.com/ppreviews-loughborough-81236/23984636/thumb.png", 103 | "defined_type": 6, 104 | "defined_type_name": "journal contribution", 105 | "group_id": 20438, 106 | "url_private_api": "api/articles/12674225", 107 | "url_public_api": "api/articles/12674225", 108 | "url_private_html": "https://figshare.com/account/articles/12674225", 109 | "url_public_html": "https://repository.lboro.ac.uk/articles/journal_contribution/Random_periodic_processes_periodic_measures_and_ergodicity/12674225", 110 | "timeline": { 111 | "posted": "2022-01-01T00:00:00", 112 | "publisherAcceptance": "2022-01-01T00:00:00", 113 | "publisherPublication": "2022-01-01T00:00:00", 114 | "firstOnline": "2022-01-01T00:00:00" 115 | }, 116 | "resource_title": "", 117 | "resource_doi": "" 118 | } 119 | ] 120 | -------------------------------------------------------------------------------- /tests/testthat/services_fs/api/account/articles.json: -------------------------------------------------------------------------------- 1 | [ 2 | 3 | ] 4 | -------------------------------------------------------------------------------- /tests/testthat/services_zen/sbapi/deposit/depositions-fa7f86.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "conceptdoi": "10.5072/zenodo.1077311", 4 | "conceptrecid": "1077311", 5 | "created": "2022-01-01T00:00:00", 6 | "doi": "10.5072/zenodo.1077312", 7 | "doi_url": "https://doi.org/10.5072/zenodo.1077312", 8 | "files": [ 9 | { 10 | "checksum": "3b6fd6ea9689be256621fb7fcc3cd81f", 11 | "filename": "DCEntry-1077312.xml", 12 | "filesize": 829, 13 | "id": "2b44d9ce-bf3f-45b1-8c59-dd24bcda6018", 14 | "links": { 15 | "download": "sbapi/files/hash/DCEntry-1077312.xml", 16 | "self": "sbapi/deposit/depositions/1077312/files/2b44d9ce-bf3f-45b1-8c59-dd24bcda6018" 17 | } 18 | }, 19 | { 20 | "checksum": "2f66f32c95d5ff3ccd3ddd1cadc797b0", 21 | "filename": "RJwrapper.pdf", 22 | "filesize": 36414, 23 | "id": "cdc0fa50-4582-4830-a6b7-63999ce736c4", 24 | "links": { 25 | "download": "sbapi/files/hash/RJwrapper.pdf", 26 | "self": "sbapi/deposit/depositions/1077312/files/cdc0fa50-4582-4830-a6b7-63999ce736c4" 27 | } 28 | } 29 | ], 30 | "id": 1077312, 31 | "links": { 32 | "badge": "https://sandbox.zenodo.org/badge/doi/10.5072/zenodo.1077312.svg", 33 | "bucket": "sbapi/files/57f59a19-a514-4e97-9273-85a65bdd267e", 34 | "conceptbadge": "https://sandbox.zenodo.org/badge/doi/10.5072/zenodo.1077311.svg", 35 | "conceptdoi": "https://doi.org/10.5072/zenodo.1077311", 36 | "discard": "sbapi/deposit/depositions/1077312/actions/discard", 37 | "doi": "https://doi.org/10.5072/zenodo.1077312", 38 | "edit": "sbapi/deposit/depositions/1077312/actions/edit", 39 | "files": "sbapi/deposit/depositions/1077312/files", 40 | "html": "https://sandbox.zenodo.org/deposit/1077312", 41 | "latest": "sbapi/records/1077312", 42 | "latest_html": "https://sandbox.zenodo.org/record/1077312", 43 | "publish": "sbapi/deposit/depositions/1077312/actions/publish", 44 | "record": "sbapi/records/1077312", 45 | "record_html": "https://sandbox.zenodo.org/record/1077312", 46 | "self": "sbapi/deposit/depositions/1077312" 47 | }, 48 | "metadata": { 49 | "access_right": "closed", 50 | "communities": [ 51 | { 52 | "identifier": "zenodo" 53 | } 54 | ], 55 | "creators": [ 56 | { 57 | "name": "A. Person,B. Person" 58 | } 59 | ], 60 | "description": "

This is the abstract<\/p>", 61 | "doi": "10.5072/zenodo.1077312", 62 | "prereserve_doi": { 63 | "doi": "10.5072/zenodo.1077312", 64 | "recid": 1077312 65 | }, 66 | "publication_date": "2022-01-01", 67 | "title": "New Title", 68 | "upload_type": "other" 69 | }, 70 | "modified": "2022-01-01T00:00:00", 71 | "owner": 115518, 72 | "record_id": 1077312, 73 | "state": "inprogress", 74 | "submitted": true, 75 | "title": "New Title" 76 | } 77 | ] 78 | -------------------------------------------------------------------------------- /tests/testthat/test-figshare-categories.R: -------------------------------------------------------------------------------- 1 | # This envvar turns off the interactive readline parts of the 2 | # figshare_categories function. 3 | Sys.setenv ("DEPOSITS_TEST_ENV" = "true") 4 | 5 | test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") | 6 | identical (Sys.getenv ("GITHUB_WORKFLOW"), "test-coverage")) 7 | 8 | testthat::skip_if (!test_all) 9 | 10 | test_that ("figsahre categories", { 11 | 12 | cats <- figshare_categories () 13 | expect_s3_class (cats, "data.frame") 14 | nms <- c ( 15 | "is_selectable", 16 | "has_children", 17 | "id", 18 | "title", 19 | "parent_id", 20 | "path", 21 | "source_id", 22 | "taxonomy_id", 23 | "p1", 24 | "p2" 25 | ) 26 | expect_identical (names (cats), nms) 27 | expect_true (nrow (cats) > 1000) 28 | }) 29 | -------------------------------------------------------------------------------- /tests/testthat/test-iso-639-languages.R: -------------------------------------------------------------------------------- 1 | 2 | test_that ("iso 639 languages", { 3 | 4 | x <- iso_639_2_language_codes () 5 | expect_type (x, "character") 6 | expect_equal (dim (x), c (546L, 2L)) 7 | expect_true (all (nchar (x [, 1]) == 3L)) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test-metadata-validate.R: -------------------------------------------------------------------------------- 1 | test_that ("metadata validate", { 2 | 3 | ORCID <- "0000-0000-0000-0000" # nolint 4 | metadata <- list ( 5 | title = "New Title", 6 | abstract = "This is the abstract", 7 | creator = list ( 8 | list (name = "A. Person", affiliation = "no", orcid = ORCID), 9 | list (name = "B. Person") 10 | ), 11 | description = paste0 ( 12 | "## description\nThis is the description\n\n", 13 | "## keywords\none, two\nthree\n\n## version\n1.0" 14 | ), 15 | not = "Not a property" 16 | ) 17 | 18 | expect_error ( 19 | suppressWarnings ( 20 | metadata_valid <- validate_metadata (metadata, service = "zenodo") 21 | ), 22 | "Stopping because the DCMI metadata terms listed above do not conform" 23 | ) 24 | 25 | metadata$not <- NULL 26 | expect_error ( # id must be integer 27 | metadata_valid <- validate_metadata (metadata, service = "figshare"), 28 | "Metadata source for \\[keywords\\] should be \\[subject\\]" 29 | ) 30 | metadata$description <- "## description\nThis is the description" 31 | metadata$subject <- "## keywords\none, two\nthree" 32 | metadata$subject <- list ( 33 | categories = list (24418L), 34 | keywords = as.list (c ("beaver", "temperature")) 35 | ) 36 | metadata$format <- "dataset" 37 | metadata$creator [[1]]$affiliation <- NULL 38 | expect_silent ( 39 | metadata_valid <- validate_metadata (metadata, service = "figshare") 40 | ) 41 | 42 | metadata$creator <- list ( 43 | list (name = "A. Person", id = "no", orcid = ORCID), 44 | list (name = "B. Person") 45 | ) 46 | expect_error ( # id must be integer 47 | metadata_valid <- validate_metadata (metadata, service = "figshare"), 48 | "Stopping because the DCMI metadata terms listed above do not conform" 49 | ) 50 | 51 | # Numeric in R still passes as integer in JSON: 52 | metadata$creator [[1]]$id <- 1 53 | expect_silent ( 54 | metadata_valid <- validate_metadata (metadata, service = "figshare") 55 | ) 56 | 57 | # But fails if passed any decimals: 58 | metadata$creator [[1]]$id <- 1.1 59 | expect_error ( 60 | metadata_valid <- validate_metadata (metadata, service = "figshare"), 61 | "Stopping because the DCMI metadata terms listed above do not conform" 62 | ) 63 | }) 64 | 65 | # Test parsing multiple metadata sources in different formats. Here, "keywords" 66 | # and "subjects" have to be specified in single DCMI "subject" field. This tests 67 | # that multiple ways of specifying these 2 fields produce same result. See #63. 68 | test_that ("metadata parsing", { 69 | 70 | 71 | service <- "zenodo" 72 | metadata <- list ( 73 | title = "New Title", 74 | abstract = "This is the abstract", 75 | creator = list (list (name = "A. Person"), list (name = "B. Person")), 76 | description = paste0 ( 77 | "## description\nThis is the description\n\n", 78 | "## version\n1.0" 79 | ), 80 | subject = "## keywords\none\ntwo, three" 81 | ) 82 | 83 | # The 2 validation calls in main client initialization: 84 | expect_silent ( 85 | metadata_dcmi1 <- validate_dcmi_metadata (metadata) 86 | ) 87 | expect_silent ( 88 | metadata_service1 <- translate_dc_to_service (metadata_dcmi1, service = service) 89 | ) 90 | 91 | # Alternative specification: 92 | metadata$subject <- list ( 93 | keywords = list ("one", "two", "three") 94 | ) 95 | expect_silent ( 96 | metadata_dcmi2 <- validate_dcmi_metadata (metadata) 97 | ) 98 | expect_silent ( 99 | metadata_service2 <- translate_dc_to_service (metadata_dcmi2, service = service) 100 | ) 101 | 102 | expect_false (identical (metadata_dcmi1, metadata_dcmi2)) 103 | 104 | # timestamps can differ: 105 | metadata_service1$created <- metadata_service2$created <- NULL 106 | expect_identical (metadata_service1, metadata_service2) 107 | }) 108 | -------------------------------------------------------------------------------- /tests/testthat/test-search.R: -------------------------------------------------------------------------------- 1 | test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") | 2 | identical (Sys.getenv ("GITHUB_WORKFLOW"), "test-coverage")) 3 | 4 | testthat::skip_if (!test_all) 5 | 6 | # This envvar is used to convert the contents of the uploaded json file to a 7 | # standardised form (uniform timestamps and article id values). 8 | Sys.setenv ("DEPOSITS_TEST_ENV" = "true") 9 | 10 | test_that ("figshare search", { 11 | 12 | cli <- with_mock_dir ("fs_create", { 13 | depositsClient$new (service = "figshare") 14 | }) 15 | 16 | x <- with_mock_dir ("search_fs", { 17 | cli$deposits_search (search_string = "random", page_size = 5L) 18 | }) 19 | 20 | expect_s3_class (x, "data.frame") 21 | expect_equal (nrow (x), 5L) 22 | expect_true (any (grepl ("random", x$title))) 23 | 24 | expect_error ( 25 | cli$deposits_search (search_string = "this", search_for = "this"), 26 | "Please specify only one of 'search_for' or 'search_string'." 27 | ) 28 | }) 29 | 30 | test_that ("zenodo search", { 31 | 32 | cli <- with_mock_dir ("zen_create", { 33 | depositsClient$new (service = "zenodo", sandbox = TRUE) 34 | }) 35 | 36 | x <- with_mock_dir ("search_zen", { 37 | cli$deposits_search (search_string = "random", page_size = 5L) 38 | }) 39 | 40 | expect_type (x, "list") 41 | expect_equal (length (x), 3L) 42 | expect_equal (names (x), c ("aggregations", "hits", "links")) 43 | 44 | meta <- x$hits$hits$metadata 45 | expect_true (any (grepl ("random", meta$description))) 46 | }) 47 | 48 | test_that ("general search errors", { 49 | 50 | cli <- with_mock_dir ("fs_create", { 51 | depositsClient$new (service = "figshare") # service doesn't matter here 52 | }) 53 | 54 | expect_error ( 55 | cli$deposits_search (search_string = 1L), 56 | "Assertion on 'search_string' failed: Must be of type 'character'" 57 | ) 58 | 59 | expect_error ( 60 | cli$deposits_search (page_size = "a"), 61 | "Assertion on 'page_size' failed: Must be of type 'single integerish value'" 62 | ) 63 | 64 | expect_error ( 65 | cli$deposits_search (page_number = "a"), 66 | "Assertion on 'page_number' failed: Must be of type 'single integerish value'" 67 | ) 68 | }) 69 | 70 | test_that ("figshare search errors", { 71 | 72 | cli <- with_mock_dir ("fs_create", { 73 | depositsClient$new (service = "figshare") # service doesn't matter here 74 | }) 75 | 76 | expect_error ( 77 | cli$deposits_search (search_string = "search string", not_an_arg = TRUE), 78 | "The parameters \\[not_an_arg\\] are not figshare search parameters" 79 | ) 80 | 81 | expect_error ( 82 | cli$deposits_search (search_string = "search string", item_type = "this"), 83 | "Assertion on '\"this\"' failed: Must be of type 'single integerish value'" 84 | ) 85 | 86 | expect_error ( 87 | cli$deposits_search (search_string = "search string", item_type = 30), 88 | "The 'item_type' parameter must be an integer between 1 and 29" 89 | ) 90 | 91 | expect_error ( 92 | cli$deposits_search (search_string = "search string", order = "not in vocab"), 93 | "The 'order' parameter must be in the specified vocabulary;" 94 | ) 95 | 96 | expect_error ( 97 | cli$deposits_search (search_string = "search string", published_since = "invalid"), 98 | "The 'published_since' parameter must be in format YYYY-MM-DD" 99 | ) 100 | 101 | expect_error ( 102 | cli$deposits_search (search_string = "search string", modified_since = "invalid"), 103 | "The 'modified_since' parameter must be in format YYYY-MM-DD" 104 | ) 105 | }) 106 | 107 | test_that ("zenodo search errors", { 108 | 109 | cli <- with_mock_dir ("zen_create", { 110 | depositsClient$new (service = "zenodo", sandbox = TRUE) 111 | }) 112 | 113 | 114 | expect_error ( 115 | cli$deposits_search (search_string = "search string", not_an_arg = TRUE), 116 | "The parameters \\[not_an_arg\\] are not zenodo search parameters" 117 | ) 118 | 119 | expect_error ( 120 | cli$deposits_search (search_string = "search string", type = 1L), 121 | "Assertion on '1L' failed: Must be of type 'character'" 122 | ) 123 | 124 | expect_error ( 125 | cli$deposits_search (search_string = "search string", all_versions = "invalid"), 126 | "The 'all_versions' parameter must be either 'false' or 'true'" 127 | ) 128 | 129 | expect_error ( 130 | cli$deposits_search (search_string = "search string", bounds = "invalid"), 131 | "The 'bounds' parameter must be in format 'bounds=x1,y1,x2,y2'" 132 | ) 133 | }) 134 | -------------------------------------------------------------------------------- /tests/testthat/test-services.R: -------------------------------------------------------------------------------- 1 | test_all <- (identical (Sys.getenv ("MPADGE_LOCAL"), "true") | 2 | identical (Sys.getenv ("GITHUB_WORKFLOW"), "test-coverage")) 3 | 4 | # This envvar is used to convert the contents of the uploaded json file to a 5 | # standardised form (uniform timestamps and article id values). 6 | Sys.setenv ("DEPOSITS_TEST_ENV" = "true") 7 | 8 | test_that ("services", { 9 | 10 | expect_silent ( 11 | s <- deposits_services () 12 | ) 13 | expect_s3_class (s, "data.frame") 14 | expect_equal (ncol (s), 3L) 15 | expect_equal (nrow (s), 3L) 16 | expect_identical (names (s), c ("name", "docs", "api_base_url")) 17 | expect_identical (s$name, c ("zenodo", "zenodo-sandbox", "figshare")) 18 | }) 19 | 20 | test_that ("tokens", { 21 | 22 | expect_error ( 23 | get_deposits_token (), 24 | "Assertion on 'service' failed" 25 | ) 26 | expect_error ( 27 | get_deposits_token ("aaaaa"), 28 | "No token found for \\[aaaaa\\]" 29 | ) 30 | 31 | testthat::skip_if (!test_all) 32 | 33 | tok <- get_deposits_token ("figshare") 34 | expect_type (tok, "character") 35 | expect_true (nchar (tok) > 1L) 36 | 37 | Sys.setenv ("junkone" = "123456") 38 | Sys.setenv ("junktwo" = "123456") 39 | expect_silent ( 40 | tok <- get_deposits_token ("junk") 41 | ) 42 | expect_equal (tok, "123456") 43 | 44 | Sys.setenv ("junktwo" = "234567") 45 | expect_error ( 46 | tok <- get_deposits_token ("junk"), 47 | "No unambiguous token found for \\[junk\\] service." 48 | ) 49 | }) 50 | 51 | testthat::skip_if (!test_all) 52 | 53 | test_that ("deposit_service function", { 54 | 55 | cli <- with_mock_dir ("services_zen", { 56 | depositsClient$new (service = "zenodo", sandbox = TRUE) 57 | }) 58 | expect_equal (cli$service, "zenodo") 59 | expect_true (cli$sandbox) 60 | expect_true (grepl ("zenodo", cli$url_base)) 61 | 62 | cli <- with_mock_dir ("services_fs", { 63 | cli$deposit_service (service = "figshare") 64 | }) 65 | expect_equal (cli$service, "figshare") 66 | expect_false (cli$sandbox) 67 | expect_true (grepl ("figshare", cli$url_base)) 68 | }) 69 | -------------------------------------------------------------------------------- /tests/testthat/zen_dl/sbapi/deposit/depositions/29712.json: -------------------------------------------------------------------------------- 1 | { 2 | "created": "2022-01-01T00:00:00+00:00", 3 | "modified": "2022-01-01T00:00:00+00:00", 4 | "id": 29712, 5 | "conceptrecid": "29711", 6 | "doi": "10.5281/zenodo.29712", 7 | "doi_url": "https://doi.org/10.5281/zenodo.29712", 8 | "metadata": { 9 | "title": "New Title", 10 | "doi": "10.5281/zenodo.29712", 11 | "publication_date": "2022-01-01", 12 | "description": "## abstract\\n\\nThis is the abstract\\n\\n## description\nThis is the description\n\n## version\n1.0", 13 | "access_right": "restricted", 14 | "creators": [ 15 | { 16 | "name": "A. Person", 17 | "affiliation": null 18 | }, 19 | { 20 | "name": "B. Person", 21 | "affiliation": null 22 | } 23 | ], 24 | "keywords": [ 25 | "one", 26 | "two", 27 | "three" 28 | ], 29 | "imprint_publisher": "Zenodo", 30 | "upload_type": "other", 31 | "prereserve_doi": { 32 | "doi": "10.5281/zenodo.29712", 33 | "recid": 29712 34 | } 35 | }, 36 | "title": "New Title", 37 | "links": { 38 | "self": "sbapi/deposit/depositions/29712", 39 | "html": "https://sandbox.zenodo.org/deposit/29712", 40 | "doi": "https://doi.org/10.5281/zenodo.29712", 41 | "badge": "https://sandbox.zenodo.org/badge/doi/10.5281%2Fzenodo.29712.svg", 42 | "files": "sbapi/deposit/depositions/29712/files", 43 | "bucket": "sbapi/files/a49586e0-347d-4e85-b63b-f6b87d3df1c1", 44 | "latest_draft": "sbapi/deposit/depositions/29712", 45 | "latest_draft_html": "https://sandbox.zenodo.org/deposit/29712", 46 | "publish": "sbapi/deposit/depositions/29712/actions/publish", 47 | "edit": "sbapi/deposit/depositions/29712/actions/edit", 48 | "discard": "sbapi/deposit/depositions/29712/actions/discard", 49 | "newversion": "sbapi/deposit/depositions/29712/actions/newversion", 50 | "registerconceptdoi": "sbapi/deposit/depositions/29712/actions/registerconceptdoi" 51 | }, 52 | "record_id": 29712, 53 | "owner": 623, 54 | "files": [ 55 | { 56 | "id": "f75a999b-dcec-483a-b80f-b7d0bee6ab33", 57 | "filename": "data.csv", 58 | "filesize": 625, 59 | "checksum": "cc624d72ede85ef061afa494d9951f6f", 60 | "links": { 61 | "self": "sbapi/deposit/depositions/29712/files/f75a999b-dcec-483a-b80f-b7d0bee6ab33", 62 | "download": "sbapi/records/29712/draft/files/data.csv/content" 63 | } 64 | }, 65 | { 66 | "id": "12062013-0739-4dd1-bfce-9a42142cf0de", 67 | "filename": "data2.csv", 68 | "filesize": 625, 69 | "checksum": "cc624d72ede85ef061afa494d9951f6f", 70 | "links": { 71 | "self": "sbapi/deposit/depositions/29712/files/12062013-0739-4dd1-bfce-9a42142cf0de", 72 | "download": "sbapi/records/29712/draft/files/data2.csv/content" 73 | } 74 | } 75 | ], 76 | "state": "unsubmitted", 77 | "submitted": false 78 | } 79 | -------------------------------------------------------------------------------- /tests/testthat/zen_dl/sbapi/records/29712/draft/files/data.csv/content.txt: -------------------------------------------------------------------------------- 1 | "","Tree","age","circumference" 2 | "1","1",118,30 3 | "2","1",484,58 4 | "3","1",664,87 5 | "4","1",1004,115 6 | "5","1",1231,120 7 | "6","1",1372,142 8 | "7","1",1582,145 9 | "8","2",118,33 10 | "9","2",484,69 11 | "10","2",664,111 12 | "11","2",1004,156 13 | "12","2",1231,172 14 | "13","2",1372,203 15 | "14","2",1582,203 16 | "15","3",118,30 17 | "16","3",484,51 18 | "17","3",664,75 19 | "18","3",1004,108 20 | "19","3",1231,115 21 | "20","3",1372,139 22 | "21","3",1582,140 23 | "22","4",118,32 24 | "23","4",484,62 25 | "24","4",664,112 26 | "25","4",1004,167 27 | "26","4",1231,179 28 | "27","4",1372,209 29 | "28","4",1582,214 30 | "29","5",118,30 31 | "30","5",484,49 32 | "31","5",664,81 33 | "32","5",1004,125 34 | "33","5",1231,142 35 | "34","5",1372,174 36 | "35","5",1582,177 37 | -------------------------------------------------------------------------------- /tests/testthat/zen_dl_fail/sbapi/deposit/depositions/29712.json: -------------------------------------------------------------------------------- 1 | { 2 | "created": "2022-01-01T00:00:00+00:00", 3 | "modified": "2022-01-01T00:00:00+00:00", 4 | "id": 29712, 5 | "conceptrecid": "29711", 6 | "doi": "10.5281/zenodo.29712", 7 | "doi_url": "https://doi.org/10.5281/zenodo.29712", 8 | "metadata": { 9 | "title": "New Title", 10 | "doi": "10.5281/zenodo.29712", 11 | "publication_date": "2022-01-01", 12 | "description": "## abstract\\n\\nThis is the abstract\\n\\n## description\nThis is the description\n\n## version\n1.0", 13 | "access_right": "restricted", 14 | "creators": [ 15 | { 16 | "name": "A. Person", 17 | "affiliation": null 18 | }, 19 | { 20 | "name": "B. Person", 21 | "affiliation": null 22 | } 23 | ], 24 | "keywords": [ 25 | "one", 26 | "two", 27 | "three" 28 | ], 29 | "imprint_publisher": "Zenodo", 30 | "upload_type": "other", 31 | "prereserve_doi": { 32 | "doi": "10.5281/zenodo.29712", 33 | "recid": 29712 34 | } 35 | }, 36 | "title": "New Title", 37 | "links": { 38 | "self": "sbapi/deposit/depositions/29712", 39 | "html": "https://sandbox.zenodo.org/deposit/29712", 40 | "doi": "https://doi.org/10.5281/zenodo.29712", 41 | "badge": "https://sandbox.zenodo.org/badge/doi/10.5281%2Fzenodo.29712.svg", 42 | "files": "sbapi/deposit/depositions/29712/files", 43 | "bucket": "sbapi/files/a49586e0-347d-4e85-b63b-f6b87d3df1c1", 44 | "latest_draft": "sbapi/deposit/depositions/29712", 45 | "latest_draft_html": "https://sandbox.zenodo.org/deposit/29712", 46 | "publish": "sbapi/deposit/depositions/29712/actions/publish", 47 | "edit": "sbapi/deposit/depositions/29712/actions/edit", 48 | "discard": "sbapi/deposit/depositions/29712/actions/discard", 49 | "newversion": "sbapi/deposit/depositions/29712/actions/newversion", 50 | "registerconceptdoi": "sbapi/deposit/depositions/29712/actions/registerconceptdoi" 51 | }, 52 | "record_id": 29712, 53 | "owner": 623, 54 | "files": [ 55 | { 56 | "id": "f75a999b-dcec-483a-b80f-b7d0bee6ab33", 57 | "filename": "data.csv", 58 | "filesize": 625, 59 | "checksum": "cc624d72ede85ef061afa494d9951f6f", 60 | "links": { 61 | "self": "sbapi/deposit/depositions/29712/files/f75a999b-dcec-483a-b80f-b7d0bee6ab33", 62 | "download": "sbapi/records/29712/draft/files/data.csv/content" 63 | } 64 | }, 65 | { 66 | "id": "12062013-0739-4dd1-bfce-9a42142cf0de", 67 | "filename": "data2.csv", 68 | "filesize": 625, 69 | "checksum": "cc624d72ede85ef061afa494d9951f6f", 70 | "links": { 71 | "self": "sbapi/deposit/depositions/29712/files/12062013-0739-4dd1-bfce-9a42142cf0de", 72 | "download": "sbapi/records/29712/draft/files/data2.csv/content" 73 | } 74 | } 75 | ], 76 | "state": "unsubmitted", 77 | "submitted": false 78 | } 79 | -------------------------------------------------------------------------------- /tests/testthat/zen_embargo/sbapi/deposit/depositions/29712-8f7fb0-PUT.json: -------------------------------------------------------------------------------- 1 | { 2 | "created": "2022-01-01T00:00:00+00:00", 3 | "modified": "2022-01-01T00:00:00+00:00", 4 | "id": 29712, 5 | "conceptrecid": "29711", 6 | "doi": "10.5281/zenodo.29712", 7 | "doi_url": "https://doi.org/10.5281/zenodo.29712", 8 | "metadata": { 9 | "title": "New Title", 10 | "doi": "10.5281/zenodo.29712", 11 | "publication_date": "2022-01-01", 12 | "description": "## abstract\\n\\nThis is the abstract\\n\\n## description\nThis is the description\n\n## version\n1.0", 13 | "access_right": "embargoed", 14 | "embargo_date": "2022-01-01", 15 | "creators": [ 16 | { 17 | "name": "A. Person", 18 | "affiliation": null 19 | }, 20 | { 21 | "name": "B. Person", 22 | "affiliation": null 23 | } 24 | ], 25 | "keywords": [ 26 | "one", 27 | "two", 28 | "three" 29 | ], 30 | "license": "cc-by-4.0", 31 | "imprint_publisher": "Zenodo", 32 | "upload_type": "other", 33 | "prereserve_doi": { 34 | "doi": "10.5281/zenodo.29712", 35 | "recid": 29712 36 | } 37 | }, 38 | "title": "New Title", 39 | "links": { 40 | "self": "sbapi/deposit/depositions/29712", 41 | "html": "https://sandbox.zenodo.org/deposit/29712", 42 | "doi": "https://doi.org/10.5281/zenodo.29712", 43 | "badge": "https://sandbox.zenodo.org/badge/doi/10.5281%2Fzenodo.29712.svg", 44 | "files": "sbapi/deposit/depositions/29712/files", 45 | "bucket": "sbapi/files/a49586e0-347d-4e85-b63b-f6b87d3df1c1", 46 | "latest_draft": "sbapi/deposit/depositions/29712", 47 | "latest_draft_html": "https://sandbox.zenodo.org/deposit/29712", 48 | "publish": "sbapi/deposit/depositions/29712/actions/publish", 49 | "edit": "sbapi/deposit/depositions/29712/actions/edit", 50 | "discard": "sbapi/deposit/depositions/29712/actions/discard", 51 | "newversion": "sbapi/deposit/depositions/29712/actions/newversion", 52 | "registerconceptdoi": "sbapi/deposit/depositions/29712/actions/registerconceptdoi" 53 | }, 54 | "record_id": 29712, 55 | "owner": 623, 56 | "files": [ 57 | 58 | ], 59 | "state": "unsubmitted", 60 | "submitted": false 61 | } 62 | -------------------------------------------------------------------------------- /tests/testthat/zen_retr/sbapi/deposit/depositions/29712.json: -------------------------------------------------------------------------------- 1 | { 2 | "created": "2022-01-01T00:00:00+00:00", 3 | "modified": "2022-01-01T00:00:00+00:00", 4 | "id": 29712, 5 | "conceptrecid": "29711", 6 | "metadata": { 7 | "title": "New Title", 8 | "publication_date": "2022-01-01", 9 | "description": "## abstract\\n\\nThis is the abstract\\n\\n## description\nThis is the description\n\n## version\n1.0", 10 | "access_right": "restricted", 11 | "creators": [ 12 | { 13 | "name": "A. Person", 14 | "affiliation": null 15 | }, 16 | { 17 | "name": "B. Person", 18 | "affiliation": null 19 | } 20 | ], 21 | "keywords": [ 22 | "one", 23 | "two", 24 | "three" 25 | ], 26 | "imprint_publisher": "Zenodo", 27 | "notes": "\\n\\n---start-deposits-meta---\\n{\"abstract\":\"This is the abstract\",\"accessRights\":\"closed\",\"creator\":[{\"name\":\"A. Person\"},{\"name\":\"B. Person\"}],\"description\":\"## description\\nThis is the description\\n\\n## version\\n1.0\",\"subject\":\"## keywords\\none, two\\nthree\",\"title\":\"New Title\"}\\n---end-deposits-meta---\\n", 28 | "upload_type": "other", 29 | "prereserve_doi": { 30 | "doi": "10.5281/zenodo.29712", 31 | "recid": 29712 32 | } 33 | }, 34 | "title": "New Title", 35 | "links": { 36 | "self": "sbapi/deposit/depositions/29712", 37 | "html": "https://sandbox.zenodo.org/deposit/29712", 38 | "badge": "https://sandbox.zenodo.org/badge/doi/.svg", 39 | "files": "sbapi/deposit/depositions/29712/files", 40 | "bucket": "sbapi/files/a49586e0-347d-4e85-b63b-f6b87d3df1c1", 41 | "latest_draft": "sbapi/deposit/depositions/29712", 42 | "latest_draft_html": "https://sandbox.zenodo.org/deposit/29712", 43 | "publish": "sbapi/deposit/depositions/29712/actions/publish", 44 | "edit": "sbapi/deposit/depositions/29712/actions/edit", 45 | "discard": "sbapi/deposit/depositions/29712/actions/discard", 46 | "newversion": "sbapi/deposit/depositions/29712/actions/newversion", 47 | "registerconceptdoi": "sbapi/deposit/depositions/29712/actions/registerconceptdoi" 48 | }, 49 | "record_id": 29712, 50 | "owner": 623, 51 | "files": [ 52 | 53 | ], 54 | "state": "unsubmitted", 55 | "submitted": false 56 | } 57 | -------------------------------------------------------------------------------- /tests/testthat/zen_up/sbapi/deposit/depositions/29712-6ea865-PUT.json: -------------------------------------------------------------------------------- 1 | { 2 | "created": "2022-01-01T00:00:00+00:00", 3 | "modified": "2022-01-01T00:00:00+00:00", 4 | "id": 29712, 5 | "conceptrecid": "29711", 6 | "doi": "10.5281/zenodo.29712", 7 | "doi_url": "https://doi.org/10.5281/zenodo.29712", 8 | "metadata": { 9 | "title": "New Title", 10 | "doi": "10.5281/zenodo.29712", 11 | "publication_date": "2022-01-01", 12 | "description": "## abstract\\n\\nThis is the abstract\\n\\n## description\nThis is the description\n\n## version\n1.0", 13 | "access_right": "restricted", 14 | "creators": [ 15 | { 16 | "name": "A. Person", 17 | "affiliation": null 18 | }, 19 | { 20 | "name": "B. Person", 21 | "affiliation": null 22 | } 23 | ], 24 | "keywords": [ 25 | "one", 26 | "two", 27 | "three" 28 | ], 29 | "imprint_publisher": "Zenodo", 30 | "upload_type": "other", 31 | "prereserve_doi": { 32 | "doi": "10.5281/zenodo.29712", 33 | "recid": 29712 34 | } 35 | }, 36 | "title": "New Title", 37 | "links": { 38 | "self": "sbapi/deposit/depositions/29712", 39 | "html": "https://sandbox.zenodo.org/deposit/29712", 40 | "doi": "https://doi.org/10.5281/zenodo.29712", 41 | "badge": "https://sandbox.zenodo.org/badge/doi/10.5281%2Fzenodo.29712.svg", 42 | "files": "sbapi/deposit/depositions/29712/files", 43 | "bucket": "sbapi/files/a49586e0-347d-4e85-b63b-f6b87d3df1c1", 44 | "latest_draft": "sbapi/deposit/depositions/29712", 45 | "latest_draft_html": "https://sandbox.zenodo.org/deposit/29712", 46 | "publish": "sbapi/deposit/depositions/29712/actions/publish", 47 | "edit": "sbapi/deposit/depositions/29712/actions/edit", 48 | "discard": "sbapi/deposit/depositions/29712/actions/discard", 49 | "newversion": "sbapi/deposit/depositions/29712/actions/newversion", 50 | "registerconceptdoi": "sbapi/deposit/depositions/29712/actions/registerconceptdoi" 51 | }, 52 | "record_id": 29712, 53 | "owner": 623, 54 | "files": [ 55 | { 56 | "id": "f75a999b-dcec-483a-b80f-b7d0bee6ab33", 57 | "filename": "data.csv", 58 | "filesize": 625, 59 | "checksum": "cc624d72ede85ef061afa494d9951f6f", 60 | "links": { 61 | "self": "sbapi/deposit/depositions/29712/files/f75a999b-dcec-483a-b80f-b7d0bee6ab33", 62 | "download": "sbapi/records/29712/draft/files/data.csv/content" 63 | } 64 | } 65 | ], 66 | "state": "unsubmitted", 67 | "submitted": false 68 | } 69 | -------------------------------------------------------------------------------- /tests/testthat/zen_up/sbapi/deposit/depositions/29712.json: -------------------------------------------------------------------------------- 1 | { 2 | "created": "2022-01-01T00:00:00+00:00", 3 | "modified": "2022-01-01T00:00:00+00:00", 4 | "id": 29712, 5 | "conceptrecid": "29711", 6 | "doi": "10.5281/zenodo.29712", 7 | "doi_url": "https://doi.org/10.5281/zenodo.29712", 8 | "metadata": { 9 | "title": "New Title", 10 | "doi": "10.5281/zenodo.29712", 11 | "publication_date": "2022-01-01", 12 | "description": "## abstract\\n\\nThis is the abstract\\n\\n## description\nThis is the description\n\n## version\n1.0", 13 | "access_right": "restricted", 14 | "creators": [ 15 | { 16 | "name": "A. Person", 17 | "affiliation": null 18 | }, 19 | { 20 | "name": "B. Person", 21 | "affiliation": null 22 | } 23 | ], 24 | "keywords": [ 25 | "one", 26 | "two", 27 | "three" 28 | ], 29 | "imprint_publisher": "Zenodo", 30 | "upload_type": "other", 31 | "prereserve_doi": { 32 | "doi": "10.5281/zenodo.29712", 33 | "recid": 29712 34 | } 35 | }, 36 | "title": "New Title", 37 | "links": { 38 | "self": "sbapi/deposit/depositions/29712", 39 | "html": "https://sandbox.zenodo.org/deposit/29712", 40 | "doi": "https://doi.org/10.5281/zenodo.29712", 41 | "badge": "https://sandbox.zenodo.org/badge/doi/10.5281%2Fzenodo.29712.svg", 42 | "files": "sbapi/deposit/depositions/29712/files", 43 | "bucket": "sbapi/files/a49586e0-347d-4e85-b63b-f6b87d3df1c1", 44 | "latest_draft": "sbapi/deposit/depositions/29712", 45 | "latest_draft_html": "https://sandbox.zenodo.org/deposit/29712", 46 | "publish": "sbapi/deposit/depositions/29712/actions/publish", 47 | "edit": "sbapi/deposit/depositions/29712/actions/edit", 48 | "discard": "sbapi/deposit/depositions/29712/actions/discard", 49 | "newversion": "sbapi/deposit/depositions/29712/actions/newversion", 50 | "registerconceptdoi": "sbapi/deposit/depositions/29712/actions/registerconceptdoi" 51 | }, 52 | "record_id": 29712, 53 | "owner": 623, 54 | "files": [ 55 | { 56 | "id": "f75a999b-dcec-483a-b80f-b7d0bee6ab33", 57 | "filename": "data.csv", 58 | "filesize": 625, 59 | "checksum": "cc624d72ede85ef061afa494d9951f6f", 60 | "links": { 61 | "self": "sbapi/deposit/depositions/29712/files/f75a999b-dcec-483a-b80f-b7d0bee6ab33", 62 | "download": "sbapi/records/29712/draft/files/data.csv/content" 63 | } 64 | } 65 | ], 66 | "state": "unsubmitted", 67 | "submitted": false 68 | } 69 | -------------------------------------------------------------------------------- /tests/testthat/zen_up/sbapi/files/hash/data.csv-861b94-PUT.R: -------------------------------------------------------------------------------- 1 | structure(list(method = "PUT", url = "sbapi/files/hash/data.csv", 2 | status_code = 201L, headers = structure(list(server = "nginx/1.24.0", 3 | date = "Mon, 19 Feb 2024 12:22:07 GMT", `content-type` = "application/json", 4 | `content-length` = "651", `x-ratelimit-limit` = "1000", 5 | `x-ratelimit-remaining` = "993", `x-ratelimit-reset` = "1708345388", 6 | `retry-after` = "60", `permissions-policy` = "interest-cohort=()", 7 | `x-frame-options` = "sameorigin", `x-xss-protection` = "1; mode=block", 8 | `x-content-type-options` = "nosniff", `content-security-policy` = "default-src 'self' fonts.googleapis.com *.gstatic.com data: 'unsafe-inline' 'unsafe-eval' blob: zenodo-broker.web.cern.ch zenodo-broker-qa.web.cern.ch maxcdn.bootstrapcdn.com cdnjs.cloudflare.com ajax.googleapis.com webanalytics.web.cern.ch", 9 | `strict-transport-security` = "max-age=31556926; includeSubDomains", 10 | `referrer-policy` = "strict-origin-when-cross-origin", 11 | `set-cookie` = "csrftoken=eyJhbGciOiJIUzUxMiIsImlhdCI6MTcwODM0NTMyNywiZXhwIjoxNzA4NDMxNzI3fQ.IlB6bUlwd3ZjZnlnMjNjM3FCeDVzU05GR2NHSVhFOUJDIg.gFA26HUlTxT29BzXvJd8-AasLk2UtvI6_pmJ8D5jO2dQLzXRAPFJh0Z8OG2MZWra_MxBzfEgOLPWfitWZwZykA; Expires=Mon, 26 Feb 2024 12:22:07 GMT; Max-Age=604800; Secure; Path=/; SameSite=Lax", 12 | `access-control-allow-origin` = "*", `access-control-expose-headers` = "Content-Type, ETag, Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset", 13 | `strict-transport-security` = "max-age=15768000", `x-request-id` = "2f46c8f030b0bc58ae1a71ed94492be3", 14 | `set-cookie` = "04f20c86f07421a9ec0f9d5ba4be544f=7705ef0ecdb4f5b5c6800bf05b654082; path=/; HttpOnly; Secure; SameSite=None"), class = "httr2_headers"), 15 | body = charToRaw("{\"created\": \"2022-01-01T00:00:00+00:00\", \"updated\": \"2022-01-01T00:00:00+00:00\", \"version_id\": \"39f591be-11aa-4ada-88af-81bf3a702d7d\", \"key\": \"data.csv\", \"size\": 625, \"mimetype\": \"text/csv\", \"checksum\": \"md5:cc624d72ede85ef061afa494d9951f6f\", \"is_head\": true, \"delete_marker\": false, \"links\": {\"self\": \"sbapi/files/hash/data.csv\", \"version\": \"sbapi/files/hash/data.csv?versionId=39f591be-11aa-4ada-88af-81bf3a702d7d\", \"uploads\": \"sbapi/files/hash/data.csv?uploads\"}}"), 16 | request = structure(list(url = "https://sandbox.zenodo.org/api/files/a49586e0-347d-4e85-b63b-f6b87d3df1c1/data.csv", 17 | method = "PUT", headers = list(Authorization = "Bearer 5BhlwRXYBj8LlyEiQtmYqeRklDjdMIKTsJM0jLN9UL8oWPFCbd7glEUpjBHz", 18 | `Content-Type` = "application/octet-stream"), body = list( 19 | data = structure("/tmp/RtmpaWqqcJ/data.csv", class = "httr2_path"), 20 | type = "raw-file", content_type = "", params = list()), 21 | fields = list(), options = list(), policies = list()), class = "httr2_request"), 22 | cache = new.env(parent = emptyenv())), class = "httr2_response") 23 | -------------------------------------------------------------------------------- /tests/testthat/zen_up2/sbapi/deposit/depositions/29712-6ea865-PUT.json: -------------------------------------------------------------------------------- 1 | { 2 | "created": "2022-01-01T00:00:00+00:00", 3 | "modified": "2022-01-01T00:00:00+00:00", 4 | "id": 29712, 5 | "conceptrecid": "29711", 6 | "doi": "10.5281/zenodo.29712", 7 | "doi_url": "https://doi.org/10.5281/zenodo.29712", 8 | "metadata": { 9 | "title": "New Title", 10 | "doi": "10.5281/zenodo.29712", 11 | "publication_date": "2022-01-01", 12 | "description": "## abstract\\n\\nThis is the abstract\\n\\n## description\nThis is the description\n\n## version\n1.0", 13 | "access_right": "restricted", 14 | "creators": [ 15 | { 16 | "name": "A. Person", 17 | "affiliation": null 18 | }, 19 | { 20 | "name": "B. Person", 21 | "affiliation": null 22 | } 23 | ], 24 | "keywords": [ 25 | "one", 26 | "two", 27 | "three" 28 | ], 29 | "imprint_publisher": "Zenodo", 30 | "upload_type": "other", 31 | "prereserve_doi": { 32 | "doi": "10.5281/zenodo.29712", 33 | "recid": 29712 34 | } 35 | }, 36 | "title": "New Title", 37 | "links": { 38 | "self": "sbapi/deposit/depositions/29712", 39 | "html": "https://sandbox.zenodo.org/deposit/29712", 40 | "doi": "https://doi.org/10.5281/zenodo.29712", 41 | "badge": "https://sandbox.zenodo.org/badge/doi/10.5281%2Fzenodo.29712.svg", 42 | "files": "sbapi/deposit/depositions/29712/files", 43 | "bucket": "sbapi/files/a49586e0-347d-4e85-b63b-f6b87d3df1c1", 44 | "latest_draft": "sbapi/deposit/depositions/29712", 45 | "latest_draft_html": "https://sandbox.zenodo.org/deposit/29712", 46 | "publish": "sbapi/deposit/depositions/29712/actions/publish", 47 | "edit": "sbapi/deposit/depositions/29712/actions/edit", 48 | "discard": "sbapi/deposit/depositions/29712/actions/discard", 49 | "newversion": "sbapi/deposit/depositions/29712/actions/newversion", 50 | "registerconceptdoi": "sbapi/deposit/depositions/29712/actions/registerconceptdoi" 51 | }, 52 | "record_id": 29712, 53 | "owner": 623, 54 | "files": [ 55 | { 56 | "id": "f75a999b-dcec-483a-b80f-b7d0bee6ab33", 57 | "filename": "data.csv", 58 | "filesize": 625, 59 | "checksum": "cc624d72ede85ef061afa494d9951f6f", 60 | "links": { 61 | "self": "sbapi/deposit/depositions/29712/files/f75a999b-dcec-483a-b80f-b7d0bee6ab33", 62 | "download": "sbapi/records/29712/draft/files/data.csv/content" 63 | } 64 | }, 65 | { 66 | "id": "12062013-0739-4dd1-bfce-9a42142cf0de", 67 | "filename": "data2.csv", 68 | "filesize": 625, 69 | "checksum": "cc624d72ede85ef061afa494d9951f6f", 70 | "links": { 71 | "self": "sbapi/deposit/depositions/29712/files/12062013-0739-4dd1-bfce-9a42142cf0de", 72 | "download": "sbapi/records/29712/draft/files/data2.csv/content" 73 | } 74 | } 75 | ], 76 | "state": "unsubmitted", 77 | "submitted": false 78 | } 79 | -------------------------------------------------------------------------------- /tests/testthat/zen_up2/sbapi/deposit/depositions/29712.json: -------------------------------------------------------------------------------- 1 | { 2 | "created": "2022-01-01T00:00:00+00:00", 3 | "modified": "2022-01-01T00:00:00+00:00", 4 | "id": 29712, 5 | "conceptrecid": "29711", 6 | "doi": "10.5281/zenodo.29712", 7 | "doi_url": "https://doi.org/10.5281/zenodo.29712", 8 | "metadata": { 9 | "title": "New Title", 10 | "doi": "10.5281/zenodo.29712", 11 | "publication_date": "2022-01-01", 12 | "description": "## abstract\\n\\nThis is the abstract\\n\\n## description\nThis is the description\n\n## version\n1.0", 13 | "access_right": "restricted", 14 | "creators": [ 15 | { 16 | "name": "A. Person", 17 | "affiliation": null 18 | }, 19 | { 20 | "name": "B. Person", 21 | "affiliation": null 22 | } 23 | ], 24 | "keywords": [ 25 | "one", 26 | "two", 27 | "three" 28 | ], 29 | "imprint_publisher": "Zenodo", 30 | "upload_type": "other", 31 | "prereserve_doi": { 32 | "doi": "10.5281/zenodo.29712", 33 | "recid": 29712 34 | } 35 | }, 36 | "title": "New Title", 37 | "links": { 38 | "self": "sbapi/deposit/depositions/29712", 39 | "html": "https://sandbox.zenodo.org/deposit/29712", 40 | "doi": "https://doi.org/10.5281/zenodo.29712", 41 | "badge": "https://sandbox.zenodo.org/badge/doi/10.5281%2Fzenodo.29712.svg", 42 | "files": "sbapi/deposit/depositions/29712/files", 43 | "bucket": "sbapi/files/a49586e0-347d-4e85-b63b-f6b87d3df1c1", 44 | "latest_draft": "sbapi/deposit/depositions/29712", 45 | "latest_draft_html": "https://sandbox.zenodo.org/deposit/29712", 46 | "publish": "sbapi/deposit/depositions/29712/actions/publish", 47 | "edit": "sbapi/deposit/depositions/29712/actions/edit", 48 | "discard": "sbapi/deposit/depositions/29712/actions/discard", 49 | "newversion": "sbapi/deposit/depositions/29712/actions/newversion", 50 | "registerconceptdoi": "sbapi/deposit/depositions/29712/actions/registerconceptdoi" 51 | }, 52 | "record_id": 29712, 53 | "owner": 623, 54 | "files": [ 55 | { 56 | "id": "f75a999b-dcec-483a-b80f-b7d0bee6ab33", 57 | "filename": "data.csv", 58 | "filesize": 625, 59 | "checksum": "cc624d72ede85ef061afa494d9951f6f", 60 | "links": { 61 | "self": "sbapi/deposit/depositions/29712/files/f75a999b-dcec-483a-b80f-b7d0bee6ab33", 62 | "download": "sbapi/records/29712/draft/files/data.csv/content" 63 | } 64 | }, 65 | { 66 | "id": "12062013-0739-4dd1-bfce-9a42142cf0de", 67 | "filename": "data2.csv", 68 | "filesize": 625, 69 | "checksum": "cc624d72ede85ef061afa494d9951f6f", 70 | "links": { 71 | "self": "sbapi/deposit/depositions/29712/files/12062013-0739-4dd1-bfce-9a42142cf0de", 72 | "download": "sbapi/records/29712/draft/files/data2.csv/content" 73 | } 74 | } 75 | ], 76 | "state": "unsubmitted", 77 | "submitted": false 78 | } 79 | -------------------------------------------------------------------------------- /tests/testthat/zen_up2/sbapi/files/hash/data2.csv-861b94-PUT.R: -------------------------------------------------------------------------------- 1 | structure(list(method = "PUT", url = "sbapi/files/hash/data2.csv", 2 | status_code = 201L, headers = structure(list(server = "nginx/1.24.0", 3 | date = "Mon, 19 Feb 2024 12:22:10 GMT", `content-type` = "application/json", 4 | `content-length` = "655", `x-ratelimit-limit` = "1000", 5 | `x-ratelimit-remaining` = "989", `x-ratelimit-reset` = "1708345389", 6 | `retry-after` = "58", `permissions-policy` = "interest-cohort=()", 7 | `x-frame-options` = "sameorigin", `x-xss-protection` = "1; mode=block", 8 | `x-content-type-options` = "nosniff", `content-security-policy` = "default-src 'self' fonts.googleapis.com *.gstatic.com data: 'unsafe-inline' 'unsafe-eval' blob: zenodo-broker.web.cern.ch zenodo-broker-qa.web.cern.ch maxcdn.bootstrapcdn.com cdnjs.cloudflare.com ajax.googleapis.com webanalytics.web.cern.ch", 9 | `strict-transport-security` = "max-age=31556926; includeSubDomains", 10 | `referrer-policy` = "strict-origin-when-cross-origin", 11 | `set-cookie` = "csrftoken=eyJhbGciOiJIUzUxMiIsImlhdCI6MTcwODM0NTMzMCwiZXhwIjoxNzA4NDMxNzMwfQ.Ilh6RUhjZ095SkE0M29wbGczckZleHkxbU1uYXpRYzJBIg.9KFaJLgVwMG911Vb54mdA6XivUJog5PmYV-z9zrgN9h5Q_dMMzTj_QvqXN5nTCRNWHwHFrlUCflCNP26MZUW3g; Expires=Mon, 26 Feb 2024 12:22:10 GMT; Max-Age=604800; Secure; Path=/; SameSite=Lax", 12 | `access-control-allow-origin` = "*", `access-control-expose-headers` = "Content-Type, ETag, Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset", 13 | `strict-transport-security` = "max-age=15768000", `x-request-id` = "97293d68ec4484a9513f5e64f8bd98c1", 14 | `set-cookie` = "04f20c86f07421a9ec0f9d5ba4be544f=7705ef0ecdb4f5b5c6800bf05b654082; path=/; HttpOnly; Secure; SameSite=None"), class = "httr2_headers"), 15 | body = charToRaw("{\"created\": \"2022-01-01T00:00:00+00:00\", \"updated\": \"2022-01-01T00:00:00+00:00\", \"version_id\": \"f6e248fc-3008-4fc0-9dbb-80fab1f47bbc\", \"key\": \"data2.csv\", \"size\": 625, \"mimetype\": \"text/csv\", \"checksum\": \"md5:cc624d72ede85ef061afa494d9951f6f\", \"is_head\": true, \"delete_marker\": false, \"links\": {\"self\": \"sbapi/files/hash/data2.csv\", \"version\": \"sbapi/files/hash/data2.csv?versionId=f6e248fc-3008-4fc0-9dbb-80fab1f47bbc\", \"uploads\": \"sbapi/files/hash/data2.csv?uploads\"}}"), 16 | request = structure(list(url = "https://sandbox.zenodo.org/api/files/a49586e0-347d-4e85-b63b-f6b87d3df1c1/data2.csv", 17 | method = "PUT", headers = list(Authorization = "Bearer 5BhlwRXYBj8LlyEiQtmYqeRklDjdMIKTsJM0jLN9UL8oWPFCbd7glEUpjBHz", 18 | `Content-Type` = "application/octet-stream"), body = list( 19 | data = structure("/tmp/RtmpaWqqcJ/data2.csv", class = "httr2_path"), 20 | type = "raw-file", content_type = "", params = list()), 21 | fields = list(), options = list(), policies = list()), class = "httr2_request"), 22 | cache = new.env(parent = emptyenv())), class = "httr2_response") 23 | -------------------------------------------------------------------------------- /tests/testthat/zen_update/sbapi/deposit/depositions/29712-455baf-PUT.json: -------------------------------------------------------------------------------- 1 | { 2 | "created": "2022-01-01T00:00:00+00:00", 3 | "modified": "2022-01-01T00:00:00+00:00", 4 | "id": 29712, 5 | "conceptrecid": "29711", 6 | "metadata": { 7 | "title": "Modified Title", 8 | "publication_date": "2022-01-01", 9 | "description": "## abstract\\n\\nThis is the modified abstract\\n\\n## description\nThis is the description\n\n## version\n1.0", 10 | "access_right": "restricted", 11 | "creators": [ 12 | { 13 | "name": "C. Person", 14 | "affiliation": null 15 | } 16 | ], 17 | "keywords": [ 18 | "one", 19 | "two", 20 | "three" 21 | ], 22 | "imprint_publisher": "Zenodo", 23 | "upload_type": "other", 24 | "prereserve_doi": { 25 | "doi": "10.5281/zenodo.29712", 26 | "recid": 29712 27 | } 28 | }, 29 | "title": "Modified Title", 30 | "links": { 31 | "self": "sbapi/deposit/depositions/29712", 32 | "html": "https://sandbox.zenodo.org/deposit/29712", 33 | "badge": "https://sandbox.zenodo.org/badge/doi/.svg", 34 | "files": "sbapi/deposit/depositions/29712/files", 35 | "bucket": "sbapi/files/a49586e0-347d-4e85-b63b-f6b87d3df1c1", 36 | "latest_draft": "sbapi/deposit/depositions/29712", 37 | "latest_draft_html": "https://sandbox.zenodo.org/deposit/29712", 38 | "publish": "sbapi/deposit/depositions/29712/actions/publish", 39 | "edit": "sbapi/deposit/depositions/29712/actions/edit", 40 | "discard": "sbapi/deposit/depositions/29712/actions/discard", 41 | "newversion": "sbapi/deposit/depositions/29712/actions/newversion", 42 | "registerconceptdoi": "sbapi/deposit/depositions/29712/actions/registerconceptdoi" 43 | }, 44 | "record_id": 29712, 45 | "owner": 623, 46 | "files": [ 47 | 48 | ], 49 | "state": "unsubmitted", 50 | "submitted": false 51 | } 52 | -------------------------------------------------------------------------------- /tests/testthat/zen_update/sbapi/deposit/depositions/29712.json: -------------------------------------------------------------------------------- 1 | { 2 | "created": "2022-01-01T00:00:00+00:00", 3 | "modified": "2022-01-01T00:00:00+00:00", 4 | "id": 29712, 5 | "conceptrecid": "29711", 6 | "metadata": { 7 | "title": "Modified Title", 8 | "publication_date": "2022-01-01", 9 | "description": "## abstract\\n\\nThis is the modified abstract\\n\\n## description\nThis is the description\n\n## version\n1.0", 10 | "access_right": "restricted", 11 | "creators": [ 12 | { 13 | "name": "C. Person", 14 | "affiliation": null 15 | } 16 | ], 17 | "keywords": [ 18 | "one", 19 | "two", 20 | "three" 21 | ], 22 | "imprint_publisher": "Zenodo", 23 | "upload_type": "other", 24 | "prereserve_doi": { 25 | "doi": "10.5281/zenodo.29712", 26 | "recid": 29712 27 | } 28 | }, 29 | "title": "Modified Title", 30 | "links": { 31 | "self": "sbapi/deposit/depositions/29712", 32 | "html": "https://sandbox.zenodo.org/deposit/29712", 33 | "badge": "https://sandbox.zenodo.org/badge/doi/.svg", 34 | "files": "sbapi/deposit/depositions/29712/files", 35 | "bucket": "sbapi/files/a49586e0-347d-4e85-b63b-f6b87d3df1c1", 36 | "latest_draft": "sbapi/deposit/depositions/29712", 37 | "latest_draft_html": "https://sandbox.zenodo.org/deposit/29712", 38 | "publish": "sbapi/deposit/depositions/29712/actions/publish", 39 | "edit": "sbapi/deposit/depositions/29712/actions/edit", 40 | "discard": "sbapi/deposit/depositions/29712/actions/discard", 41 | "newversion": "sbapi/deposit/depositions/29712/actions/newversion", 42 | "registerconceptdoi": "sbapi/deposit/depositions/29712/actions/registerconceptdoi" 43 | }, 44 | "record_id": 29712, 45 | "owner": 623, 46 | "files": [ 47 | 48 | ], 49 | "state": "unsubmitted", 50 | "submitted": false 51 | } 52 | -------------------------------------------------------------------------------- /tests/testthat/zen_update_dp/sbapi/deposit/depositions/29712-342c38-PUT.json: -------------------------------------------------------------------------------- 1 | { 2 | "created": "2022-01-01T00:00:00+00:00", 3 | "modified": "2022-01-01T00:00:00+00:00", 4 | "id": 29712, 5 | "conceptrecid": "29711", 6 | "doi": "10.5281/zenodo.29712", 7 | "doi_url": "https://doi.org/10.5281/zenodo.29712", 8 | "metadata": { 9 | "title": "New Title", 10 | "doi": "10.5281/zenodo.29712", 11 | "publication_date": "2022-01-01", 12 | "description": "## abstract\\n\\nThis is the abstract\\n\\n## description\nThis is the description\n\n## version\n1.0", 13 | "access_right": "restricted", 14 | "creators": [ 15 | { 16 | "name": "A. Person", 17 | "affiliation": null 18 | }, 19 | { 20 | "name": "B. Person", 21 | "affiliation": null 22 | } 23 | ], 24 | "keywords": [ 25 | "one", 26 | "two", 27 | "three" 28 | ], 29 | "imprint_publisher": "Zenodo", 30 | "upload_type": "other", 31 | "prereserve_doi": { 32 | "doi": "10.5281/zenodo.29712", 33 | "recid": 29712 34 | } 35 | }, 36 | "title": "New Title", 37 | "links": { 38 | "self": "sbapi/deposit/depositions/29712", 39 | "html": "https://sandbox.zenodo.org/deposit/29712", 40 | "doi": "https://doi.org/10.5281/zenodo.29712", 41 | "badge": "https://sandbox.zenodo.org/badge/doi/10.5281%2Fzenodo.29712.svg", 42 | "files": "sbapi/deposit/depositions/29712/files", 43 | "bucket": "sbapi/files/a49586e0-347d-4e85-b63b-f6b87d3df1c1", 44 | "latest_draft": "sbapi/deposit/depositions/29712", 45 | "latest_draft_html": "https://sandbox.zenodo.org/deposit/29712", 46 | "publish": "sbapi/deposit/depositions/29712/actions/publish", 47 | "edit": "sbapi/deposit/depositions/29712/actions/edit", 48 | "discard": "sbapi/deposit/depositions/29712/actions/discard", 49 | "newversion": "sbapi/deposit/depositions/29712/actions/newversion", 50 | "registerconceptdoi": "sbapi/deposit/depositions/29712/actions/registerconceptdoi" 51 | }, 52 | "record_id": 29712, 53 | "owner": 623, 54 | "files": [ 55 | { 56 | "id": "f75a999b-dcec-483a-b80f-b7d0bee6ab33", 57 | "filename": "data.csv", 58 | "filesize": 625, 59 | "checksum": "cc624d72ede85ef061afa494d9951f6f", 60 | "links": { 61 | "self": "sbapi/deposit/depositions/29712/files/f75a999b-dcec-483a-b80f-b7d0bee6ab33", 62 | "download": "sbapi/records/29712/draft/files/data.csv/content" 63 | } 64 | }, 65 | { 66 | "id": "12062013-0739-4dd1-bfce-9a42142cf0de", 67 | "filename": "data2.csv", 68 | "filesize": 625, 69 | "checksum": "cc624d72ede85ef061afa494d9951f6f", 70 | "links": { 71 | "self": "sbapi/deposit/depositions/29712/files/12062013-0739-4dd1-bfce-9a42142cf0de", 72 | "download": "sbapi/records/29712/draft/files/data2.csv/content" 73 | } 74 | } 75 | ], 76 | "state": "unsubmitted", 77 | "submitted": false 78 | } 79 | -------------------------------------------------------------------------------- /vignettes/deposits-R6.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "The deposits R6 client" 3 | author: 4 | - "Mark Padgham" 5 | date: "`r Sys.Date()`" 6 | vignette: > 7 | %\VignetteIndexEntry{2. The deposits R6 client} 8 | %\VignetteEngine{knitr::rmarkdown} 9 | %\VignetteEncoding{UTF-8} 10 | --- 11 | 12 | ```{r setup, include=FALSE} 13 | knitr::opts_chunk$set ( 14 | collapse = TRUE, 15 | warning = TRUE, 16 | message = TRUE, 17 | width = 120, 18 | comment = "#>", 19 | fig.retina = 2, 20 | fig.path = "README-" 21 | ) 22 | ``` 23 | 24 | The deposits package uses [an `R6` client](https://github.com/r-lib/R6) to 25 | interface with the individual deposition services. This vignette briefly 26 | explains explains the properties of a deposits client for those unfamiliar 27 | with `R6` objects. 28 | 29 | ### R6 methods 30 | 31 | The `R6` package used to construct deposits clients here allows for 32 | structured class objects in R. The objects include elements (such as variables) 33 | and methods, which for R are generally functions. A new client can be 34 | constructed with the `new` operator, which for deposits requires specifying 35 | the service for which the client is to be constructed: 36 | 37 | ```{r new-cli, eval = FALSE} 38 | library (deposits) 39 | cli <- depositsClient$new (service = "figshare") 40 | ``` 41 | 42 | Additional functions are called in a similar way, using a `$`-notation, in the 43 | form `cli$deposit_function()`. The deposits package is constructed so that 44 | function calls constructed is this way will "automatically" update the object 45 | itself, and so generally do not need to be assigned to a return value. For 46 | example, the function `deposits_list()` updates the list of deposits on the 47 | associated service. In conventional R packages, calling this function would 48 | require assigning a return value like this: 49 | 50 | ```{r cli-list-deps, eval = FALSE} 51 | cli_updated <- cli$deposits_list () 52 | ``` 53 | 54 | `R6` objects are, however, always updated internally, so the client itself, 55 | `cli`, will already include the updated list of deposits without any need for 56 | assigning the return value to `cli_updated`. That is, rather than the above 57 | line, all deposits functions may be called simply as, 58 | 59 | ```{r cli-list-deps2, eval = FALSE} 60 | cli$deposits_list () 61 | ``` 62 | 63 | (The single exception to this is the `deposit_download_file()` function, which 64 | returns the path to the locally downloaded file, and so should always be 65 | assigned to a return value.) 66 | 67 | 68 | ### Initialising a deposits client 69 | 70 | An empty client can be constructed by naming the desired service. An additional 71 | `sandbox` parameter constructs a client to the `zenodo` sandbox environment 72 | intended for testing their API. Actual use of the `zenodo` API can then be 73 | enabled with the default `sandbox = FALSE`. 74 | 75 | ```{r client-new, eval = FALSE} 76 | cli <- depositsClient$new ("zenodo", sandbox = TRUE) 77 | cli 78 | #> 79 | #> deposits service : zenodo 80 | #> sandbox: TRUE 81 | #> url_base : https://sandbox.zenodo.org/api/ 82 | #> Current deposits : 83 | #> 84 | #> hostdata : 85 | #> metadata : 86 | ``` 87 | 88 | ### The R6 client structure 89 | 90 | All `R6` clients share a few build-in methods which can be used to understand 91 | their internal structure and functionality. In particular, both [the 92 | `ls()`](https://stat.ethz.ch/R-manual/R-devel/library/base/html/ls.html) and 93 | [str() 94 | function](https://stat.ethz.ch/R-manual/R-devel/library/utils/html/str.html)s 95 | reveal internal details of R6 clients. These details are nevertheless not 96 | particularly helpful here, and the deposits client has it's own 97 | [`deposits_methods()` 98 | function](https://docs.ropensci.org/deposits/reference/depositsClient.html#method-deposits-methods-) 99 | intended to provide an overview all all implemented methods: 100 | 101 | ```{r methods, eval = FALSE} 102 | cli$deposits_methods () 103 | #> List of methods for a deposits client: 104 | #> 105 | #> - deposit_add_resource 106 | #> - deposit_delete 107 | #> - deposit_delete_file 108 | #> - deposit_download_file 109 | #> - deposit_embargo 110 | #> - deposit_fill_metadata 111 | #> - deposit_new 112 | #> - deposit_prereserve_doi 113 | #> - deposit_publish 114 | #> - deposit_retrieve 115 | #> - deposit_service 116 | #> - deposit_update 117 | #> - deposit_upload_file 118 | #> - deposit_version 119 | #> - deposits_list 120 | #> - deposits_methods 121 | #> - deposits_search 122 | #> 123 | #> see `?depositsClient` for full details of all methods. 124 | ``` 125 | 126 | As described in the final line of that output, the documentation contains full 127 | details of all methods, also provided in [the online 128 | documentation](https://docs.ropensci.org/deposits/reference/depositsClient.html#methods). 129 | -------------------------------------------------------------------------------- /vignettes/fig1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ropenscilabs/deposits/3495041f03c4d29c58f392cb46e7a621aeece0c6/vignettes/fig1.png -------------------------------------------------------------------------------- /vignettes/fig1.tex: -------------------------------------------------------------------------------- 1 | %\documentclass[tikz,convert={outfile=\jobname.svg},border=5pt]{standalone} 2 | \documentclass[tikz,border=15pt]{standalone} 3 | \usepackage[utf8x]{inputenc} 4 | \usetikzlibrary{positioning} 5 | \usetikzlibrary{decorations.text} 6 | % To create the .png: 7 | % > pdflatex fig1.tex 8 | % > convert -density 300 fig1.pdf -quality 100 fig1.png 9 | 10 | \begin{document} 11 | \begin{tikzpicture}[font=\footnotesize] 12 | \tikzstyle{node_style} = [rounded corners, rectangle, fill=orange] 13 | \tikzstyle{arrow_style1} = [->, black, line width=1, >=latex, shorten <=0.5pt, shorten >=0.5pt] 14 | 15 | \node[node_style] (n1) {Local Storage}; 16 | \node[node_style] (n2) [above=3cm of n1] {`deposits' Client}; 17 | \node[node_style] (n3) [above=3cm of n2] {Remote Service}; 18 | 19 | \draw [ 20 | arrow_style1, 21 | postaction={ 22 | decorate, 23 | decoration={ 24 | raise=0.8ex, 25 | text along path, 26 | text align=center, 27 | text={|\sffamily\scriptsize|fill{\_}metadata} 28 | } 29 | }, 30 | postaction={ 31 | decorate, 32 | decoration={ 33 | raise=-1.5ex, 34 | text along path, 35 | text align=center, 36 | text={|\sffamily\scriptsize|update} 37 | } 38 | }, 39 | transform canvas={xshift=-4mm} 40 | ] (n1) to [bend left=20] (n2); 41 | 42 | \draw [ 43 | arrow_style1, 44 | postaction={ 45 | decorate, 46 | decoration={ 47 | raise=0.8ex, 48 | text along path, 49 | text align=center, 50 | text={|\sffamily\scriptsize|(add{\_}resource)} 51 | } 52 | }, 53 | postaction={ 54 | decorate, 55 | decoration={ 56 | raise=-1.5ex, 57 | text along path, 58 | text align=center, 59 | text={|\sffamily\scriptsize|(upload{\_}file)} 60 | } 61 | }, 62 | transform canvas={xshift=3mm} 63 | ] (n2) to [bend left=20] (n1); 64 | 65 | \draw [ 66 | arrow_style1, 67 | postaction={ 68 | decorate, 69 | decoration={ 70 | raise=0.8ex, 71 | text along path, 72 | text align=center, 73 | text={|\sffamily\scriptsize|update} 74 | } 75 | }, 76 | postaction={ 77 | decorate, 78 | decoration={ 79 | raise=-1.2ex, 80 | text along path, 81 | text align=center, 82 | text={|\sffamily\scriptsize|new} 83 | } 84 | }, 85 | transform canvas={xshift=-4mm} 86 | ] (n2) to [bend left=20] (n3); 87 | 88 | \draw [ 89 | arrow_style1, 90 | postaction={ 91 | decorate, 92 | decoration={ 93 | raise=0.5ex, 94 | text along path, 95 | text align=center, 96 | text={|\sffamily\scriptsize|retrieve} 97 | } 98 | }, 99 | transform canvas={xshift=3mm} 100 | ] (n3) to [bend left=20] (n2); 101 | 102 | 103 | \draw [ 104 | arrow_style1, 105 | postaction={ 106 | decorate, 107 | decoration={ 108 | raise=-1.5ex, 109 | text along path, 110 | text align=center, 111 | text={|\sffamily\scriptsize|upload{\_}file, update} 112 | } 113 | }, 114 | transform canvas={xshift=-6mm} 115 | ] (n1) to [bend left=30] (n3); 116 | 117 | \draw [ 118 | arrow_style1, 119 | postaction={ 120 | decorate, 121 | decoration={ 122 | raise=-1.5ex, 123 | text along path, 124 | text align=center, 125 | text={|\sffamily\scriptsize|download{\_}file} 126 | } 127 | }, 128 | transform canvas={xshift=6mm} 129 | ] (n3) to [bend left=30] (n1); 130 | 131 | \end{tikzpicture} 132 | 133 | \end{document} 134 | -------------------------------------------------------------------------------- /vignettes/install-setup.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Installation and Setup" 3 | author: 4 | - "Mark Padgham" 5 | date: "`r Sys.Date()`" 6 | vignette: > 7 | %\VignetteIndexEntry{1. Installation and Setup} 8 | %\VignetteEngine{knitr::rmarkdown} 9 | %\VignetteEncoding{UTF-8} 10 | --- 11 | 12 | ```{r setup, include=FALSE} 13 | knitr::opts_chunk$set ( 14 | collapse = TRUE, 15 | warning = TRUE, 16 | message = TRUE, 17 | width = 120, 18 | comment = "#>", 19 | fig.retina = 2, 20 | fig.path = "README-" 21 | ) 22 | ``` 23 | 24 | ## Installation 25 | 26 | The package can be installed by enabling the ["ropensci" 27 | r-universe](https://ropensci.r-universe.dev), and using `install.packages()`: 28 | 29 | ```{r r-univ, eval = FALSE} 30 | options (repos = c ( 31 | ropensci = "https://ropensci.r-universe.dev", 32 | CRAN = "https://cloud.r-project.org" 33 | )) 34 | install.packages ("deposits") 35 | ``` 36 | 37 | Alternatively, the package can be installed directly from GitHub with the 38 | following command: 39 | 40 | ```{r remotes-install, eval = FALSE} 41 | remotes::install_github ("ropenscilabs/deposits") 42 | ``` 43 | 44 | The package can then be loaded for use with: 45 | 46 | ```{r} 47 | library (deposits) 48 | ``` 49 | 50 | ## Setup: API Tokens 51 | 52 | All services require users to create an account and then to generate API 53 | ("Application Programming Interface") tokens. Click on the following links to 54 | generate tokens, also listed as sequences of menu items used to reach token 55 | settings: 56 | 57 | - [zenodo/account/settings/applications/tokens/new](https://zenodo.org/account/settings/applications/tokens/new/) 58 | - [zenodo-sandbox/account/settings/applications/tokens/new](https://sandbox.zenodo.org/account/settings/applications/tokens/new/), 59 | - [figshare/account/applications](https://figshare.com/account/applications). 60 | 61 | It is not necessary to create or register applications on any of these 62 | services; this package uses personal tokens only. The tokens need to be 63 | stored as local environment variables the names of which must include the names 64 | of the respective services, as defined by the "name" column returned from 65 | `deposits_service()`, as shown above. This can be done as in the following 66 | example: 67 | 68 | ```{r key, eval = FALSE} 69 | Sys.setenv ("ZENODO_SANDBOX_TOKEN" = "