From 9a81816922d9e69b898de9635eeb7e316d471818 Mon Sep 17 00:00:00 2001 From: nuest Date: Sun, 14 Jan 2018 22:14:12 +0100 Subject: [PATCH] add first test for measurements --- tests/testthat/test_measurements.R | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/testthat/test_measurements.R diff --git a/tests/testthat/test_measurements.R b/tests/testthat/test_measurements.R new file mode 100644 index 0000000..14bcd54 --- /dev/null +++ b/tests/testthat/test_measurements.R @@ -0,0 +1,25 @@ +context("measurements") + +check_api <- function() { + code <- NA + try(code <- httr::status_code(httr::GET(osem_endpoint()))) + if (is.na(code)) skip("API not available") +} + +try({ + boxes <- osem_boxes() + }) + +test_that("measurements of specific boxes can be retrieved for one phenomenon and returns a measurements data.frame", { + check_api() + + # fix for subsetting + class(boxes) <- c("data.frame") + three_boxes <- boxes[1:3,] + three_boxes <- osem_as_sensebox(three_boxes) + phens <- names(osem_phenomena(three_boxes)) + + measurements <- osem_measurements(x = three_boxes, phenomenon = phens[[1]]) + expect_true(is.data.frame(measurements)) + expect_true("osem_measurements" %in% class(measurements)) +})