1
0
Fork 0
mirror of https://github.com/sensebox/opensensmapr synced 2025-02-23 07:53:58 +01:00
opensensmapR/tests/testthat/test_phenomena.R

36 lines
869 B
R
Raw Normal View History

source('testhelpers.R')
context('phenomena')
2018-01-14 21:49:51 +01:00
try({
boxes = osem_boxes()
all_phen = unique(unlist(boxes$phenomena))
2018-01-14 21:49:51 +01:00
})
test_that('phenomena from boxes is a list of counts', {
2018-01-14 21:49:51 +01:00
check_api()
2018-01-15 15:25:18 +01:00
phenomena = osem_phenomena(boxes)
2018-01-15 15:25:18 +01:00
2018-01-14 21:49:51 +01:00
expect_true(is.numeric(unlist(phenomena)))
expect_true(is.list(phenomena))
})
test_that('phenomena from boxes has all phenomena', {
2018-01-14 21:49:51 +01:00
check_api()
2018-01-15 15:25:18 +01:00
phenomena = osem_phenomena(boxes)
2018-01-15 15:25:18 +01:00
2018-01-14 21:49:51 +01:00
expect_true(all(all_phen %in% names(phenomena)))
expect_true(all(names(phenomena) %in% all_phen))
})
test_that('phenomena from a not sensebox data.frame returns error', {
check_api()
expect_error(osem_phenomena(list()), 'no applicable method')
expect_error(osem_phenomena(data.frame()), 'no applicable method')
boxes_df = boxes
class(boxes_df) = c('data.frame')
expect_error(osem_phenomena(boxes_df), 'no applicable method')
2018-01-14 21:49:51 +01:00
})