/
test-get_data_dict.R
38 lines (31 loc) · 1.09 KB
/
test-get_data_dict.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
context("get_data_dict")
## Data dict summary data
data_dict <- get_data_dict(download_data = TRUE,
save = TRUE)
ncols_dict <- ncol(data_dict)
nrows_dict <- nrow(data_dict)
class_dict <- class(data_dict)[1]
## Expected
exp_nrows <- 1
exp_ncols <- 1
exp_class <- "tbl_df"
test_that("Data dictionary has been successfully downloaded", {
expect_true(!is.null(data_dict))
})
test_that("Data dictionary is a tibble",{
expect_equal(exp_class, class_dict)
})
test_that("Data dictionary has at least the expected number of variables", {
expect_true(exp_ncols <= ncols_dict)
})
test_that("Data dictionary has at least the expected number of entries", {
expect_true(exp_nrows <= nrows_dict)
})
test_that("Data dictionary is the same when downloaded using utils::read.csv.
Not testing definitions as encoded differently", {
skip_on_cran()
expect_equal(data_dict[-ncol(data_dict)],
get_data_dict(download_data = TRUE,
use_utils = TRUE,
dict_save_name = "dict_with_utils")[,-ncol(data_dict)])
})