context("http")
test_that("http works", {
skip_on_cran()
aa1 <- api("http://api.plos.org/search") %>%
api_query(q = ecology, wt = json, fl = 'id,journal')
aa2 <- api("http://api.plos.org/search") %>%
api_query(q = ecology, wt = json, fl = 'id,journal') %>%
peep()
expect_is(aa1, "list")
expect_is(aa2, "req")
expect_identical(aa1, aa2 %>% http)
expect_identical(http(api_oauth2(api("https://api.github.com"), token = Sys.getenv("GITHUB_PAT"))),
api("https://api.github.com") %>% api_oauth2(token = Sys.getenv("GITHUB_PAT")) %>% http
)
x <- api("http://httpbin.org/post") %>%
api_body(x = "A simple text string") %>%
http("POST")
expect_is(x, "list")
})
test_that("http fails well", {
skip_on_cran()
expect_error(http(), "argument \"req\" is missing")
expect_error(http(api("https://api.github.com"), method = "FART"),
"method must be one of GET, POST, or PUT")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.