Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/testthat/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ setup_test_data <- function() {
DTIteration <- data.table(
id = 1:observations,
chi_geo_kc = sample(c('King County',NA_character_), observations, replace = T),
chi_race_7 = factor(sample(c("Asian", "AIAN", "Black", "Hispanic", "NHPI", "White", "Other", "Multiple", NA), observations, replace = T, prob = c(.19,.01,.07,.11,.01,.35,.07,.14,.02)), levels = c("Asian", "AIAN", "Black", "Hispanic", "NHPI", "White", "Other", "Multiple", NA)),
race4 = factor(sample(c("Asian", "AIAN", "Black", "Hispanic", "NHPI", "White", "Multiple", NA), observations, replace = T, prob = c(.19,.01,.07,.11,.01,.42,.14,.02)), levels = c("Asian", "AIAN", "Black", "Hispanic", "NHPI", "White", "Other", "Multiple", NA)),
chi_sex = as.factor(sample(c("Male","Female"), observations, replace = T)),
chi_geo_region = factor(sample(c("South", "North", "Seattle", "East"), observations, replace = T), levels = c("South","North","Seattle","East")),
indicator1 = as.factor(sample(c("never","sometimes", "always", NA), observations, replace = T)),
Expand Down Expand Up @@ -382,7 +382,7 @@ setup_test_data <- function() {
test_analysis_set_twosets <- data.table(
#this should work with the generic data set
cat1 = rep(c('Regions', 'Gender', 'Race/ethnicity'),2),
cat1_varname = rep(c('chi_geo_region', 'chi_sex', 'chi_race_7'),2),
cat1_varname = rep(c('chi_geo_region', 'chi_sex', 'race4'),2),
`_kingcounty` = c('x'),
`_wastate` = NA_character_,
demgroups = c(rep(NA_character_,3),rep("x", 3)),
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test-chi_calc.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test_that("chi_calc performs basic calculations correctly", {
DTgeneric <- test_data$my.generic_data
#make a denominator come out as 0
DTgeneric$indicator
DTgeneric[chi_race_7 == "White" , indicator1 := "never"]
DTgeneric[race4 == "White" , indicator1 := "never"]
result <- chi_calc(
ph.data = DTgeneric,
ph.instructions = instruction,
Expand All @@ -18,7 +18,6 @@ test_that("chi_calc performs basic calculations correctly", {
small_num_suppress = F
)


expect_s3_class(result, "data.table")
expect_true(all(c("result", "lower_bound", "upper_bound") %in% names(result)))
expect_true(all(result$result >= 0 & result$result <= 1)) # For proportions
Expand Down