# 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]]
scenario_original <- scenario
# get and change the constraints list ready to test in function
constraints_list <- get_constraints_input_tables(scenario, user_period = "month")
constraints_list[[1]] <- constraints_list[[1]] %>%
dplyr::mutate(max = ifelse(channel == "TV",
6000,
max))
scenario <- set_scenario_constraints(scenario, constraints_list)
test_that("function returns correctly", {
# test it changes the val correctly
df <- get_constraints(scenario)
df_filter <- df %>%
dplyr::filter(constraint.group_id == 1) %>%
dplyr::filter(channel_name == "TV")
expect_equal(df_filter %>% dplyr::pull(constraint_min), 1500)
expect_equal(df_filter %>% dplyr::pull(constraint_max), 6000)
# check the cols are formatted correctly
expect_equal(scenario$constraints %>% names(),
scenario_original$constraints %>% names())
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.