# work around to ensure the package can read in the data
# needs to be saved in the inst folder
# updated to work off multiple project scenarios
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[[3]]
# period <- get_scenario_period(scenario)[1]
# get_scenario_kpi1(scenario, period)
# before run optimisataion -------------------------------------
# period_list <- purrr::map(scenario_multiple,
# get_scenario_period) %>% purrr::map(1)
# this needs to be excecuted differently to combine into a list
kpi1_list <- purrr::map(scenario_multiple,
get_scenario_kpi1,
"month")
output_multiple <- kpi1_list
kpi1_list2 <- purrr::map(scenario_multiple,
get_scenario_kpi1,
"month",
type = "selected")
output_multiple2 <- kpi1_list2
test_that("get_scenario_kpi returns a string", {
expect_equal(lapply(output_multiple, typeof) %>% unlist(),
rep("character", length(output_multiple)))
expect_true(lapply(output_multiple, length)[1] >= 1)
expect_true((lapply(output_multiple[1], nchar)[1] %>% unlist() > 0)[1])
expect_equal(lapply(output_multiple2, typeof) %>% unlist(),
rep("character", length(output_multiple2)))
expect_true(lapply(output_multiple2, length)[1] >= 1)
expect_true((lapply(output_multiple2[1], nchar)[1] %>% unlist() == 0)[1])
})
# after run optimisatation -------------------------------------
# scenario_multiple <- lapply(scenario_multiple,
# add_optim_elements,
# subset_kpi_level1_id = 1,
# subset_kpi_level2_id = 1,
# subset_kpi_level3_id = 1,
# subset_period_level1 = "month")
# this function doesn't run for one of the three scenarios
# scenario_multiple <- lapply(scenario_multiple,
# run_optim)
# test_that("get_scenario_period returns a string", {
# expect_equal(typeof(output), "character")
# expect_equal(typeof(output2), "character")
# expect_true(length(output) >= 1)
# expect_true(nchar(output[1]) > 0)
# expect_true(nchar(output2) > 0)
# })
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.