3
if(0){ # skip publishing tests. These were all still passing at last check, but rfigshare configuration for testing is not ideal.
7
# This loads the rOpenSci figshare sandbox credentials, so that the example
8
# can run automatically during check and install. Unlike normal figshare accounts,
9
# data loaded to this testing sandbox is periodically purged.
11
status <- try(fs_auth(token = "xdBjcKOiunwjiovwkfTF2QjGhROeLMw0y0nSCSgvg3YQxdBjcKOiunwjiovwkfTF2Q", token_secret = "4mdM3pfekNGO16X4hsvZdg"))
12
if(is(status, "try-error") || (is(status, "response") && status$status_code != 200)){
13
warning("Could not authenticate figshare, skipping figshare tests")
18
## Create example file
22
geiger_nex <- add_trees(geospiza$phy)
23
geiger_nex <- add_characters(geospiza$dat, geiger_nex)
24
geiger_nex <- add_basic_meta(
25
title = "Geospiza phylogeny with character data rendered as NeXML",
26
creator = "Carl Boettiger",
27
description = "This example NeXML file was created using the data originally provided in the geiger package for R to illustrate how this data can be stored, shared and distributed as NeXML.",
28
citation = citation("geiger"),
32
test_that("We can publish to figshare", {
35
id <- nexml_publish(geiger_nex, visibility="public", repo="figshare")
38
## Download and parse publication
39
## Note that at present, only public files can be automatically downloaded from figshare
41
test_nex <- nexml_read(fs_download(id))
43
## Extract and compare metadata from upload and download
44
m <- get_metadata(geiger_nex)
45
test_m <- get_metadata(test_nex)
46
expect_equal(m["dc:title"], test_m["dc:title"])
47
expect_equal(m["dc:description"], test_m["dc:description"])
49
## Check that DOI resolves -- doesn't for the test account
51
#page <- GET(test_m[["dc:identifier"]])
52
#expect_equal(page$status_code, 200)
55
# Check that we avoid repeated metadata entries
57
expect_equal(sum(match(names(test_m), "dc:pubdate"), na.rm=TRUE), 1)
58
expect_equal(sum(match(names(test_m), "cc:license"), na.rm=TRUE), 1)