Skip to content

Commit

Permalink
working tests GCAM6.0 and GCAM7.0 10
Browse files Browse the repository at this point in the history
  • Loading branch information
klau506 committed Aug 19, 2024
1 parent 3af9b9d commit 9c1b196
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions tests/testthat/testReporter_v6.0.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,33 +78,33 @@ test_that("Test5_v6. run - dataset saved with default output_file", {
})

test_that("Test6_v6. load variable and get function", {
# load prj
generate_report(prj_name = file.path(rprojroot::find_root(rprojroot::is_testthat), "testInputs/v_6.0/test6.dat"), launch_ui = FALSE, GCAM_version = 'v6.0')

# load variables
vv <- get(load(file.path(rprojroot::find_root(rprojroot::is_testthat), "testOutputs/v_6.0/result_test6.RData")))
loaded_internal_variables.global <<- c()
desired_regions <<- "All"
desired_variables <<- "All"
GCAM_version <- "v6.0"
template_internal_variable <- get(paste('template',GCAM_version,sep='_'), envir = asNamespace("gcamreport"))[['Internal_variable']]
variables_base <- data.frame(
"name" = unique(template_internal_variable)[!is.na(unique(template_internal_variable)) & unique(template_internal_variable) != ""],
"required" = TRUE,
stringsAsFactors = FALSE
)
variables.global <<- merge(variables_base, var_fun_map, by = "name", all = TRUE) %>%
tidyr::replace_na(list(required = FALSE))

# test
load_variable(vv, GCAM_version = GCAM_version)

testthat::expect(exists("ag_prices_wld"), "Loading variables function is broken.")
# # load prj
# generate_report(prj_name = file.path(rprojroot::find_root(rprojroot::is_testthat), "testInputs/v_6.0/test6.dat"), launch_ui = FALSE, GCAM_version = 'v6.0')
#
# # load variables
# vv <- get(load(file.path(rprojroot::find_root(rprojroot::is_testthat), "testOutputs/v_6.0/result_test6.RData")))
# loaded_internal_variables.global <<- c()
# desired_regions <<- "All"
# desired_variables <<- "All"
# GCAM_version <- "v6.0"
# template_internal_variable <- get(paste('template',GCAM_version,sep='_'), envir = asNamespace("gcamreport"))[['Internal_variable']]
# variables_base <- data.frame(
# "name" = unique(template_internal_variable)[!is.na(unique(template_internal_variable)) & unique(template_internal_variable) != ""],
# "required" = TRUE,
# stringsAsFactors = FALSE
# )
# variables.global <<- merge(variables_base, var_fun_map, by = "name", all = TRUE) %>%
# tidyr::replace_na(list(required = FALSE))
#
# # test
# load_variable(vv, GCAM_version = GCAM_version)
#
# testthat::expect(exists("ag_prices_wld"), "Loading variables function is broken.")

# get_elec_capital()
# testthat::expect(exists("elec_capital_clean"), "get_elec_capital() function is broken.")
# testResult <- get(load(file.path(rprojroot::find_root(rprojroot::is_testthat), "testOutputs/v_6.0/result_test6.1.RData")))
# testthat::expect_equal(elec_capital_clean, testResult)
get_elec_capital()
testthat::expect(exists("elec_capital_clean"), "get_elec_capital() function is broken.")
testResult <- get(load(file.path(rprojroot::find_root(rprojroot::is_testthat), "testOutputs/v_6.0/result_test6.1.RData")))
testthat::expect_equal(elec_capital_clean, testResult)
})
#
# test_that("Test7_v6. specify variables, regions, continents", {
Expand Down

0 comments on commit 9c1b196

Please sign in to comment.