increase test coverage

pull/17/head
nuest 6 years ago
parent 5f6dc7c0b5
commit d82b538b7a

@ -106,8 +106,9 @@ parse_get_measurements_params = function (params) {
if (is.null(params$phenomenon) | is.na(params$phenomenon))
stop('Parameter "phenomenon" is required')
if (!is.na(params$from) && is.na(params$to))
stop('specify "from" only together with "to"')
if ((!is.na(params$from) && is.na(params$to)) ||
(!is.na(params$to) && is.na(params$from))
) stop('specify "from" only together with "to"')
if (
(!is.null(params$bbox) && !is.null(params$boxes)) ||

@ -17,6 +17,11 @@ test_that("a list of all boxes can be retrieved and returns a sensebox data.fram
expect_true(any("sensebox" %in% class(boxes)))
})
test_that("both from and to are required when requesting boxes, error otherwise", {
expect_error(osem_boxes(from = as.POSIXct("2017-01-01")), "must be used together")
expect_error(osem_boxes(to = as.POSIXct("2017-01-01")), "must be used together")
})
test_that("a list of boxes with exposure filter returns only the requested exposure", {
check_api()

@ -91,3 +91,7 @@ test_that("measurements can be retrieved for a time period", {
expect_true(all(measurements$createdAt > from_date))
})
test_that("both from and to are required when requesting measurements, error otherwise", {
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")
})

Loading…
Cancel
Save