tests/testthat/test-create_scenario.R

path <- system.file("testdata", "three1", "scenario_0", package = "mm.reoptimise")
scenario <- create_scenario(path)

element_names <- c("name",
                   "curves",
                   "kpi",
                   "kpi.level1",
                   "kpi.level2",
                   "kpi.level3",
                   "channel",
                   "channel.group.level1",
                   "channel.group.level2",
                   "channel.group.level3",
                   "period",
                   "alloc.unit",
                   "settings",
                   "constraints_settings",
                   "constraints",
                   "weights",
                   "curves_filtered",
                   "curves_full",
                   "kpi_weights")

test_that("output is a list with expected length and data types", {
   expect_type(scenario, "list")
   expect_length(scenario, 19)
   expect_named(scenario, element_names)
   expect_true(tibble::is_tibble(scenario$curves_full))
   expect_true(tibble::is_tibble(scenario$name))
})

path <- system.file("testdata", "tnz1", "scenario_0", package = "mm.reoptimise")
scenario <- create_scenario(path)

element_names <- c("name",
                   "curves",
                   "kpi",
                   "kpi.level1",
                   "kpi.level2",
                   "kpi.level3",
                   "channel",
                   "channel.group.level1",
                   "channel.group.level2",
                   "channel.group.level3",
                   "period",
                   "alloc.unit",
                   "settings",
                   "constraints_settings",
                   "constraints",
                   "weights",
                   "curves_filtered",
                   "curves_full",
                   "kpi_weights")

test_that("output is a list with expected length and data types", {
   expect_type(scenario, "list")
   expect_length(scenario, 19)
   expect_named(scenario, element_names)
   expect_true(tibble::is_tibble(scenario$curves_full))
   expect_true(tibble::is_tibble(scenario$name))
})
cath-parkinson/mm.reoptimise documentation built on May 12, 2022, 3:34 p.m.