context("test-station_ids.R") api_unavailable <- function(){ resp1 <- httr::GET(url = "https://nrfaapps.ceh.ac.uk/nrfa/ws/time-series", query = list(format = "json-object", station = 39001,`data-type` = "gdf"), httr::user_agent("https://github.com/ilapros/rnrfa")) resp2 <- httr::GET(url = "https://nrfaapps.ceh.ac.uk/nrfa/ws/time-series", query = list(format = "json-object", station = 39001,`data-type` = "cmr"), httr::user_agent("https://github.com/ilapros/rnrfa")) # if any of the two streams is not working skip tests (httr::http_error(resp1) | httr::http_error(resp2)) } test_that("station_ids works", { skip_if(api_unavailable(), "API not available") x <- station_ids() expect_equal(length(x) >= 1580, TRUE) })