|
|
|
@ -21,14 +21,16 @@ test_that("measurements can be retrieved for a phenomenon", {
|
|
|
|
|
|
|
|
|
|
test_that("measurement retrieval does not give progress information in non-interactive mode", {
|
|
|
|
|
check_api()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!opensensmapr:::is_non_interactive()) skip("interactive session")
|
|
|
|
|
|
|
|
|
|
out <- capture.output(measurements <- osem_measurements(x = "Licht"))
|
|
|
|
|
expect_length(out, 0)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test_that("a response with no matching senseBoxes gives an error", {
|
|
|
|
|
check_api()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect_error(osem_measurements(x = "Windgeschwindigkeit", exposure = "indoor"), "No senseBoxes found")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
@ -70,10 +72,10 @@ test_that("measurements of specific boxes can be retrieved for one phenomenon an
|
|
|
|
|
|
|
|
|
|
test_that("measurements can be retrieved for a bounding box", {
|
|
|
|
|
check_api()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sfc <- sf::st_sfc(sf::st_linestring(x = matrix(data = c(7, 8, 50, 51), ncol = 2)), crs = 4326)
|
|
|
|
|
bbox <- sf::st_bbox(sfc)
|
|
|
|
|
measurements <- osem_measurements(x = bbox, phenomenon = "Temperatur")
|
|
|
|
|
measurements <- osem_measurements(x = bbox, phenomenon = "Windrichtung")
|
|
|
|
|
expect_true(all(unique(measurements$lat) > 50))
|
|
|
|
|
expect_true(all(unique(measurements$lat) < 51))
|
|
|
|
|
expect_true(all(unique(measurements$lon) < 8))
|
|
|
|
@ -82,11 +84,22 @@ test_that("measurements can be retrieved for a bounding box", {
|
|
|
|
|
|
|
|
|
|
test_that("measurements can be retrieved for a time period", {
|
|
|
|
|
check_api()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from_date <- as.POSIXct("2018-01-01 12:00:00")
|
|
|
|
|
to_date <- as.POSIXct("2018-01-01 13:00:00")
|
|
|
|
|
measurements <- osem_measurements(x = "Temperature", from = from_date, to = to_date)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect_true(all(measurements$createdAt < to_date))
|
|
|
|
|
expect_true(all(measurements$createdAt > from_date))
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test_that("measurements can be retrieved for a time period > 31 days", {
|
|
|
|
|
check_api()
|
|
|
|
|
|
|
|
|
|
from_date <- as.POSIXct("2017-11-01 12:00:00")
|
|
|
|
|
to_date <- as.POSIXct("2018-01-01 13:00:00")
|
|
|
|
|
measurements <- osem_measurements(x = "Windrichtung", from = from_date, to = to_date)
|
|
|
|
|
|
|
|
|
|
expect_true(all(measurements$createdAt < to_date))
|
|
|
|
|
expect_true(all(measurements$createdAt > from_date))
|
|
|
|
|
})
|
|
|
|
@ -95,3 +108,13 @@ test_that("both from and to are required when requesting measurements, error oth
|
|
|
|
|
expect_error(osem_measurements(x = "Temperature", from = as.POSIXct("2017-01-01")), "only together with")
|
|
|
|
|
expect_error(osem_measurements(x = "Temperature", to = as.POSIXct("2017-01-01")), "only together with")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test_that("[.osem_measurements maintains attributes", {
|
|
|
|
|
check_api()
|
|
|
|
|
|
|
|
|
|
sfc <- sf::st_sfc(sf::st_linestring(x = matrix(data = c(7, 8, 50, 51), ncol = 2)), crs = 4326)
|
|
|
|
|
bbox <- sf::st_bbox(sfc)
|
|
|
|
|
m <- osem_measurements(x = bbox, phenomenon = "Windrichtung")
|
|
|
|
|
|
|
|
|
|
expect_true(all(attributes(m[1:nrow(m), ]) %in% attributes(m)))
|
|
|
|
|
})
|
|
|
|
|