# 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)
# NOTE: update this to test all scenarios in the folder via map / map2
scenario <- scenario_multiple[[1]]
period <- get_scenario_period(scenario, type = "all")
kpi1 <- get_scenario_kpi1(scenario, period[1])
kpi2 <- get_scenario_kpi2(scenario, period[1], kpi1[2])
kpi3 <- get_scenario_kpi3(scenario, period[1], kpi1[2], kpi2[1])
scenario1 <- set_scenario_period(scenario, period = period[1])
scenario1 <- set_scenario_kpi(scenario1, kpi1[2], kpi2[1], kpi3[1])
test_that("function returns correctly", {
expect_equal(class(scenario1), "list")
expect_equal(class(scenario1$curves_filtered)[1], "tbl_df")
expect_equal(scenario1$curves_filtered %>% dplyr::pull(period_level1) %>% unique(),
get_scenario_period(scenario1)[1])
expect_true(scenario1$curves_filtered %>% nrow() %>% sum() > 0)
})
scenario2 <- set_scenario_period(scenario, period = period[1])
scenario2 <- set_scenario_kpi(scenario2, kpi1[2])
test_that("function returns correctly", {
expect_equal(scenario2$curves_filtered %>% dplyr::pull(kpi.level1_name) %>% unique(),
get_scenario_kpi1(scenario2, period[1])[2])
})
# NOTE: add a test to check we can pass this to a scenario and run an optimisation
# check we can pass this scenario and run a optimisation
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.