2018-05-07 01:09:57 +02:00
|
|
|
source('testhelpers.R')
|
|
|
|
context('counts')
|
2018-01-14 21:48:46 +01:00
|
|
|
|
2018-05-07 01:09:57 +02:00
|
|
|
test_that('counts can be retrieved as a list of numbers', {
|
2018-01-14 21:48:46 +01:00
|
|
|
check_api()
|
2018-01-15 15:25:18 +01:00
|
|
|
|
2018-05-07 01:09:57 +02:00
|
|
|
counts = osem_counts()
|
2018-01-15 15:25:18 +01:00
|
|
|
|
2018-01-14 21:48:46 +01:00
|
|
|
expect_true(is.list(counts))
|
|
|
|
expect_true(is.numeric(unlist(counts)))
|
|
|
|
expect_length(counts, 3)
|
|
|
|
})
|
2018-05-25 01:34:47 +02:00
|
|
|
|
|
|
|
test_that('requests can be cached', {
|
|
|
|
check_api()
|
|
|
|
|
|
|
|
osem_clear_cache()
|
|
|
|
expect_length(list.files(tempdir(), pattern = 'osemcache\\..*\\.rds'), 0)
|
|
|
|
c = osem_counts(cache = tempdir())
|
|
|
|
|
|
|
|
cacheFile = paste(
|
|
|
|
tempdir(),
|
|
|
|
opensensmapr:::osem_cache_filename('/stats'),
|
|
|
|
sep = '/'
|
|
|
|
)
|
|
|
|
expect_true(file.exists(cacheFile))
|
|
|
|
expect_length(list.files(tempdir(), pattern = 'osemcache\\..*\\.rds'), 1)
|
|
|
|
|
|
|
|
# no download output (works only in interactive mode..)
|
|
|
|
out = capture.output({
|
|
|
|
c = osem_counts(cache = tempdir())
|
|
|
|
})
|
|
|
|
expect_length(out, 0)
|
|
|
|
expect_length(list.files(tempdir(), pattern = 'osemcache\\..*\\.rds'), 1)
|
|
|
|
|
|
|
|
osem_clear_cache()
|
|
|
|
expect_length(list.files(tempdir(), pattern = 'osemcache\\..*\\.rds'), 0)
|
|
|
|
})
|