add function wrapper for default endpoint
parent
d3d758d554
commit
ef3fb7f4bb
@ -0,0 +1,14 @@
|
||||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/api.R
|
||||
\name{osem_endpoint}
|
||||
\alias{osem_endpoint}
|
||||
\title{Get the default openSenseMap API endpoint}
|
||||
\usage{
|
||||
osem_endpoint()
|
||||
}
|
||||
\value{
|
||||
A character string with the HTTP URL of the openSenseMap API
|
||||
}
|
||||
\description{
|
||||
Get the default openSenseMap API endpoint
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
context("counts")
|
||||
|
||||
check_api <- function() {
|
||||
code <- NA
|
||||
try(code <- httr::status_code(httr::GET(osem_endpoint())))
|
||||
if (is.na(code)) skip("API not available")
|
||||
}
|
||||
|
||||
test_that("counts can be retrieved as a list of numbers", {
|
||||
check_api()
|
||||
|
||||
counts <- osem_counts()
|
||||
|
||||
expect_true(is.list(counts))
|
||||
expect_true(is.numeric(unlist(counts)))
|
||||
expect_length(counts, 3)
|
||||
})
|
Loading…
Reference in New Issue