Skip to content

Commit

Permalink
add some tests for the generic transform data method
Browse files Browse the repository at this point in the history
  • Loading branch information
seabbs committed Dec 2, 2024
1 parent 9c0d9a2 commit 0712992
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/test-transform_data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
test_that(
"epidist_transform_data with default settings returns data unchanged",
{
family <- epidist_family(prep_obs, family = lognormal())
formula <- epidist_formula(prep_obs, family = family, formula = bf(mu ~ 1))

transformed <- epidist_transform_data(prep_obs, family, formula)
expect_identical(transformed, prep_obs)
}
)

test_that("epidist_transform_data errors when passed incorrect inputs", {
family <- epidist_family(prep_obs, family = lognormal())
formula <- epidist_formula(prep_obs, family = family, formula = bf(mu ~ 1))

expect_error(epidist_transform_data(list(), family, formula))
})

test_that("epidist_transform_data_model.default returns data unchanged", {
family <- epidist_family(prep_obs, family = lognormal())
formula <- epidist_formula(prep_obs, family = family, formula = bf(mu ~ 1))

transformed <- epidist_transform_data_model(prep_obs, family, formula)
expect_identical(transformed, prep_obs)
})

test_that("epidist_transform_data works with different model types", {
family <- epidist_family(prep_obs, family = lognormal())
formula <- epidist_formula(prep_obs, family = family, formula = bf(mu ~ 1))

expect_identical(
epidist_transform_data(prep_naive_obs, family, formula),
prep_naive_obs
)
expect_identical(
epidist_transform_data(prep_obs_gamma, family, formula),
prep_obs_gamma
)
})

0 comments on commit 0712992

Please sign in to comment.