tests/testthat/test-est_naloxone.R

test_that("Accepts input with missing distribution frequency", {
  # generate distribution data with frequency of every three months
  d <- generate_model_data(reporting_freq = 3)
  # note iter should be at least 2000 to generate a reasonable posterior sample
  fit <- est_naloxone(d, iter = 200, chains = 2)
  expect_s4_class(fit, "stanfit")
})

test_that("Error if Reported_Distributed and Reported_Used number of missing
          don't match", {
  d <- generate_model_data(reporting_freq = 3)
  d["Reported_Distributed"] <- NA
  testthat::expect_error(
    est_naloxone(d, iter = 200, chains = 2)
  )
})

Try the bennu package in your browser

Any scripts or data that you put into this service are public.

bennu documentation built on Sept. 14, 2023, 1:08 a.m.