tests/testthat/test-get_constraints_input_tables.R

# work around to ensure the package can read in the data
# needs to be saved in the inst folder
path <- system.file("testdata", "three1", "scenario_0", package = "mm.reoptimise") # not ran
path2 <- system.file("testdata", "three2", "scenario_0", package = "mm.reoptimise") # not ran
path3 <- system.file("testdata", "three1", "scenario_1", package = "mm.reoptimise") # already ran

path <- c(path, path2, path3)
scenario_multiple <- purrr::map(path, create_scenario)

scenario <- scenario_multiple[[1]]
user_period <- "month"

list_tables <- get_constraints_input_tables(scenario, user_period)

test_that("function returns correctly", {

      expect_equal(typeof(list_tables), "list")

      test <- purrr::map(list_tables, class) %>% purrr::map_chr(1)
      test <- test == "tbl_df"
      expect_true(test %>% all())

      test <- purrr::map_int(list_tables, nrow) > 0
      expect_true(test %>% all())


})
cath-parkinson/mm.reoptimise documentation built on May 12, 2022, 3:34 p.m.