context("Source length")
library(rcordis)
library(httr)
test_that("get_source returns the expected url", {
# projects ---
expect_equal(
get_source(8, "projects"),
"https://cordis.europa.eu/data/cordis-h2020projects.csv")
expect_equal(
get_source(7, "projects"),
"https://cordis.europa.eu/data/cordis-fp7projects.csv")
expect_equal(
get_source(6, "projects"),
"https://cordis.europa.eu/data/FP6/cordis-fp6projects.csv")
# organizations ---
expect_equal(
get_source(8, "organizations"),
"https://cordis.europa.eu/data/cordis-h2020organizations.csv")
expect_equal(
get_source(7, "organizations"),
"https://cordis.europa.eu/data/cordis-fp7organizations.csv")
expect_equal(
get_source(6, "organizations"),
"https://cordis.europa.eu/data/FP6/cordis-fp6organizations.csv")
# reports ---
expect_equal(
get_source(8, "reports"),
"https://cordis.europa.eu/data/cordis-h2020reports.csv")
expect_equal(
get_source(7, "reports"),
"https://cordis.europa.eu/data/cordis-fp7reports.csv")
# boundaries ---
expect_error(get_source(7, "something else")) # no other what
expect_error(get_source(6, "reports")) # no reports for < fp7
expect_error(get_source(0)) # out of range
expect_error(get_source(9)) # out of range
})
test_that("get_source() returns valid urls", {
# projects ---
expect_false(http_error(get_source(8, "projects")))
expect_false(http_error(get_source(7, "projects")))
expect_false(http_error(get_source(6, "projects")))
# organizations ---
expect_false(http_error(get_source(8, "organizations")))
expect_false(http_error(get_source(7, "organizations")))
expect_false(http_error(get_source(6, "organizations")))
# reports ---
expect_false(http_error(get_source(8, "reports")))
expect_false(http_error(get_source(7, "reports")))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.