Skip to content

Commit

Permalink
decommented tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BERTHET Clement (Externe) committed Oct 16, 2023
1 parent 4c02ee7 commit 71ebb1a
Show file tree
Hide file tree
Showing 8 changed files with 2,753 additions and 2,753 deletions.
1,906 changes: 953 additions & 953 deletions tests/testthat/test-exchangesStack.R

Large diffs are not rendered by default.

94 changes: 47 additions & 47 deletions tests/testthat/test-graphUtils.R
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
# context(".compOpts")
#
#
# test_that(".compOpts", {
#
# expect_true(.compOpts("", "cp")$ncharts == 2)
# expect_true(.compOpts("", NULL)$ncharts == 1)
# expect_true(.compOpts(list(), NULL)$ncharts == 1)
# })
#
# if(.requireRhdf5_Antares(stopP = FALSE)){
# context(".dateRangeJoin")
# test_that(".dateRangeJoin", {
# dt <- list()
# dt$x <- list(list(dateRange = as.Date(c("2010-01-01", "2010-01-10"))),
# list(dateRange = as.Date(c("2010-01-02", "2010-01-09"))))
#
#
#
#
# expect_true(.dateRangeJoin(dt, "union", "min") == as.Date("2010-01-01"))
# expect_true(.dateRangeJoin(dt, "union", "max") == as.Date("2010-01-10"))
# expect_true(.dateRangeJoin(dt, "intersect", "max") == as.Date("2010-01-09"))
# expect_true(.dateRangeJoin(dt, "intersect", "min") == as.Date("2010-01-02"))
#
# dt2 <- list()
# dt2$x <- list(list(ar = list(dateRange = as.Date(c("2010-01-01", "2010-01-10")))),
# list(ar = list(dateRange = as.Date(c("2010-01-02", "2010-01-09")))))
#
# expect_true(.dateRangeJoin(dt2, "union", "min", "ar") == as.Date("2010-01-01"))
# expect_true(.dateRangeJoin(dt2, "union", "max", "ar") == as.Date("2010-01-10"))
# expect_true(.dateRangeJoin(dt2, "intersect", "max", "ar") == as.Date("2010-01-09"))
# expect_true(.dateRangeJoin(dt2, "intersect", "min", "ar") == as.Date("2010-01-02"))
#
# })
#
# context(".loadH5Data")
# test_that(".loadH5Data", {
# opts <- setSimulationPath(studyPath)
# sharerequest <- list()
# sharerequest$mcYearh_l <- "all"
# sharerequest$tables_l <- c("areas", "links", "clusters", "districts")
# sharerequest$timeSteph5_l <- "hourly"
# expect_true("antaresDataList" %in% class(.loadH5Data(sharerequest, opts)))
#
# })
# }
context(".compOpts")


test_that(".compOpts", {

expect_true(.compOpts("", "cp")$ncharts == 2)
expect_true(.compOpts("", NULL)$ncharts == 1)
expect_true(.compOpts(list(), NULL)$ncharts == 1)
})

if(.requireRhdf5_Antares(stopP = FALSE)){
context(".dateRangeJoin")
test_that(".dateRangeJoin", {
dt <- list()
dt$x <- list(list(dateRange = as.Date(c("2010-01-01", "2010-01-10"))),
list(dateRange = as.Date(c("2010-01-02", "2010-01-09"))))




expect_true(.dateRangeJoin(dt, "union", "min") == as.Date("2010-01-01"))
expect_true(.dateRangeJoin(dt, "union", "max") == as.Date("2010-01-10"))
expect_true(.dateRangeJoin(dt, "intersect", "max") == as.Date("2010-01-09"))
expect_true(.dateRangeJoin(dt, "intersect", "min") == as.Date("2010-01-02"))

dt2 <- list()
dt2$x <- list(list(ar = list(dateRange = as.Date(c("2010-01-01", "2010-01-10")))),
list(ar = list(dateRange = as.Date(c("2010-01-02", "2010-01-09")))))

expect_true(.dateRangeJoin(dt2, "union", "min", "ar") == as.Date("2010-01-01"))
expect_true(.dateRangeJoin(dt2, "union", "max", "ar") == as.Date("2010-01-10"))
expect_true(.dateRangeJoin(dt2, "intersect", "max", "ar") == as.Date("2010-01-09"))
expect_true(.dateRangeJoin(dt2, "intersect", "min", "ar") == as.Date("2010-01-02"))

})

context(".loadH5Data")
test_that(".loadH5Data", {
opts <- setSimulationPath(studyPath)
sharerequest <- list()
sharerequest$mcYearh_l <- "all"
sharerequest$tables_l <- c("areas", "links", "clusters", "districts")
sharerequest$timeSteph5_l <- "hourly"
expect_true("antaresDataList" %in% class(.loadH5Data(sharerequest, opts)))

})
}
270 changes: 135 additions & 135 deletions tests/testthat/test-plotMap.R
Original file line number Diff line number Diff line change
@@ -1,138 +1,138 @@
# context("plotMap")
#
# test_that("plotMap, no interactive", {
#
# dta <- readAntares(areas = "all", links = "all", showProgress = FALSE)
# testClass <- function(obj){
# class(obj)[1] == 'combineWidgets'
# }
# load(system.file("mapLayout/ml.rda", package = "antaresViz"))
#
# listArgs <- list(noarg = list(x = dta, interactive = FALSE, mapLayout = ml),
# colorLinks = list(x = dta, interactive = FALSE, mapLayout = ml, colLinkVar = "FLOW LIN."),
# colorAll = list(x = dta, interactive = FALSE, mapLayout = ml, colLinkVar = "FLOW LIN.",
# colAreaVar = "OP. COST")
# )
#
# lapply(listArgs, function(X){
# re1 <- do.call(plotMap, X)
# expect_true(testClass(re1))
# })
#
# })
#
# test_that("plotMap, no interactive return error", {
#
# dta <- readAntares(areas = "all", links = "all", showProgress = FALSE)
# load(system.file("mapLayout/ml.rda", package = "antaresViz"))
#
# expect_error(plotMap(x = dta, mapLayout = ml , interactive = FALSE, compare = "areas"))
#
#
# })
#
# test_that("plotMap, interactive", {
# dta <- readAntares(areas = "all", links = "all", showProgress = FALSE)
# load(system.file("mapLayout/ml.rda", package = "antaresViz"))
# VV <- plotMap(x = dta, mapLayout = ml, .runApp = FALSE, interactive = TRUE)
# VV$init()
# expect_true("MWController" %in% class(VV))
# })
#
# test_that("plotMap, no interactive, x and refStudy are antaresDataList", {
# dta <- readAntares(areas = "all", links = "all", showProgress = FALSE)
# load(system.file("mapLayout/ml.rda", package = "antaresViz"))
# resPlotMap <- plotMap(x = dta,
# mapLayout = ml,
# interactive = FALSE,
# colAreaVar = "LOAD",
# sizeAreaVars = c("LOAD", "WIND", "SOLAR"))
# expect_true("htmlwidget" %in% class(resPlotMap))
# valToValid <- .getDataFromPlotMap(area = "c",
# time = "sam. 05 mai 2018<br/>17:00",
# variable = "LOAD",
# htmlPlotMap = resPlotMap)
# expect_gt(valToValid, 50000)
# # with refStudy
# resPlotMap <- plotMap(x = dta,
# refStudy = dta,
# mapLayout = ml,
# interactive = FALSE,
# colAreaVar = "LOAD",
# sizeAreaVars = c("LOAD", "WIND", "SOLAR"))
# expect_true("htmlwidget" %in% class(resPlotMap))
# valToValid <- .getDataFromPlotMap(area = "c",
# time = "sam. 05 mai 2018<br/>17:00",
# variable = "LOAD",
# htmlPlotMap = resPlotMap)
# expect_equal(valToValid, 0)
# # edit myData
# data2 <- readAntares(areas = "all", links = "all", showProgress = FALSE)
# data2$areas[ , LOAD := as.double(LOAD)][area=="c", LOAD := as.double(LOAD +2500.0)]
# resPlotMap2 <- plotMap(x = data2,
# refStudy = dta,
# mapLayout = ml,
# interactive = FALSE,
# colAreaVar = "LOAD",
# sizeAreaVars = c("LOAD", "WIND", "SOLAR"))
# expect_true("htmlwidget" %in% class(resPlotMap2))
# valToValid <- .getDataFromPlotMap(area = "c",
# time = "sam. 05 mai 2018<br/>17:00",
# variable = "LOAD",
# htmlPlotMap = resPlotMap2)
# expect_equal(valToValid, 2500)
# })
#
# test_that("plotMap, no interactive, x is a list of antaresDataList and refStudy an antaresDataList", {
# data1 <- readAntares(areas = "all", links = "all", showProgress = FALSE)
# dataList <- list(data1, data1, data1)
# load(system.file("mapLayout/ml.rda", package = "antaresViz"))
# resPlotMap <- plotMap(x = dataList,
# mapLayout = ml,
# interactive = FALSE,
# colAreaVar = "LOAD",
# sizeAreaVars = c("LOAD", "WIND", "SOLAR"))
# expect_true("htmlwidget" %in% class(resPlotMap))
# valToValid <- .getDataFromPlotMap(area = "c",
# time = "sam. 05 mai 2018<br/>17:00",
# variable = "LOAD",
# htmlPlotMap = resPlotMap,
# idWidget = 2)
# expect_gt(valToValid, 50000)
# # with refStudy
# resPlotMap <- plotMap(x = dataList,
# refStudy = data1,
# mapLayout = ml,
# interactive = FALSE,
# colAreaVar = "LOAD",
# sizeAreaVars = c("LOAD", "WIND", "SOLAR"))
# expect_true("htmlwidget" %in% class(resPlotMap))
# valToValid <- .getDataFromPlotMap(area = "c",
# time = "sam. 05 mai 2018<br/>17:00",
# variable = "LOAD",
# htmlPlotMap = resPlotMap,
# idWidget = 2)
# expect_equal(valToValid, 0)
# # edit myData
# data2 <- readAntares(areas = "all", links = "all", showProgress = FALSE)
# data1 <- readAntares(areas = "all", links = "all", showProgress = FALSE)
# data2$areas[ , LOAD := as.double(LOAD)][area=="c", LOAD := as.double(LOAD +2500.0)]
# dataList2 <- list(data1, data2, data1)
# expect_equal(dataList2[[2]]$areas[area=="c", LOAD], dataList2[[1]]$areas[area=="c", LOAD] + 2500)
# resPlotMap2 <- plotMap(x = dataList2,
# refStudy = data1,
# mapLayout = ml,
# interactive = FALSE,
# colAreaVar = "LOAD",
# sizeAreaVars = c("LOAD", "WIND", "SOLAR"))
# expect_true("htmlwidget" %in% class(resPlotMap2))
# valToValid <- .getDataFromPlotMap(area = "c",
# time = "sam. 05 mai 2018<br/>17:00",
# variable = "LOAD",
# htmlPlotMap = resPlotMap2,
# idWidget = 2)
# expect_equal(valToValid, 2500)
# })
context("plotMap")

test_that("plotMap, no interactive", {

dta <- readAntares(areas = "all", links = "all", showProgress = FALSE)
testClass <- function(obj){
class(obj)[1] == 'combineWidgets'
}
load(system.file("mapLayout/ml.rda", package = "antaresViz"))

listArgs <- list(noarg = list(x = dta, interactive = FALSE, mapLayout = ml),
colorLinks = list(x = dta, interactive = FALSE, mapLayout = ml, colLinkVar = "FLOW LIN."),
colorAll = list(x = dta, interactive = FALSE, mapLayout = ml, colLinkVar = "FLOW LIN.",
colAreaVar = "OP. COST")
)

lapply(listArgs, function(X){
re1 <- do.call(plotMap, X)
expect_true(testClass(re1))
})

})

test_that("plotMap, no interactive return error", {

dta <- readAntares(areas = "all", links = "all", showProgress = FALSE)
load(system.file("mapLayout/ml.rda", package = "antaresViz"))

expect_error(plotMap(x = dta, mapLayout = ml , interactive = FALSE, compare = "areas"))


})

test_that("plotMap, interactive", {
dta <- readAntares(areas = "all", links = "all", showProgress = FALSE)
load(system.file("mapLayout/ml.rda", package = "antaresViz"))
VV <- plotMap(x = dta, mapLayout = ml, .runApp = FALSE, interactive = TRUE)
VV$init()
expect_true("MWController" %in% class(VV))
})

test_that("plotMap, no interactive, x and refStudy are antaresDataList", {
dta <- readAntares(areas = "all", links = "all", showProgress = FALSE)
load(system.file("mapLayout/ml.rda", package = "antaresViz"))
resPlotMap <- plotMap(x = dta,
mapLayout = ml,
interactive = FALSE,
colAreaVar = "LOAD",
sizeAreaVars = c("LOAD", "WIND", "SOLAR"))
expect_true("htmlwidget" %in% class(resPlotMap))
valToValid <- .getDataFromPlotMap(area = "c",
time = "sam. 05 mai 2018<br/>17:00",
variable = "LOAD",
htmlPlotMap = resPlotMap)
expect_gt(valToValid, 50000)
# with refStudy
resPlotMap <- plotMap(x = dta,
refStudy = dta,
mapLayout = ml,
interactive = FALSE,
colAreaVar = "LOAD",
sizeAreaVars = c("LOAD", "WIND", "SOLAR"))
expect_true("htmlwidget" %in% class(resPlotMap))
valToValid <- .getDataFromPlotMap(area = "c",
time = "sam. 05 mai 2018<br/>17:00",
variable = "LOAD",
htmlPlotMap = resPlotMap)
expect_equal(valToValid, 0)
# edit myData
data2 <- readAntares(areas = "all", links = "all", showProgress = FALSE)
data2$areas[ , LOAD := as.double(LOAD)][area=="c", LOAD := as.double(LOAD +2500.0)]
resPlotMap2 <- plotMap(x = data2,
refStudy = dta,
mapLayout = ml,
interactive = FALSE,
colAreaVar = "LOAD",
sizeAreaVars = c("LOAD", "WIND", "SOLAR"))
expect_true("htmlwidget" %in% class(resPlotMap2))
valToValid <- .getDataFromPlotMap(area = "c",
time = "sam. 05 mai 2018<br/>17:00",
variable = "LOAD",
htmlPlotMap = resPlotMap2)
expect_equal(valToValid, 2500)
})

test_that("plotMap, no interactive, x is a list of antaresDataList and refStudy an antaresDataList", {
data1 <- readAntares(areas = "all", links = "all", showProgress = FALSE)
dataList <- list(data1, data1, data1)
load(system.file("mapLayout/ml.rda", package = "antaresViz"))
resPlotMap <- plotMap(x = dataList,
mapLayout = ml,
interactive = FALSE,
colAreaVar = "LOAD",
sizeAreaVars = c("LOAD", "WIND", "SOLAR"))
expect_true("htmlwidget" %in% class(resPlotMap))
valToValid <- .getDataFromPlotMap(area = "c",
time = "sam. 05 mai 2018<br/>17:00",
variable = "LOAD",
htmlPlotMap = resPlotMap,
idWidget = 2)
expect_gt(valToValid, 50000)
# with refStudy
resPlotMap <- plotMap(x = dataList,
refStudy = data1,
mapLayout = ml,
interactive = FALSE,
colAreaVar = "LOAD",
sizeAreaVars = c("LOAD", "WIND", "SOLAR"))
expect_true("htmlwidget" %in% class(resPlotMap))
valToValid <- .getDataFromPlotMap(area = "c",
time = "sam. 05 mai 2018<br/>17:00",
variable = "LOAD",
htmlPlotMap = resPlotMap,
idWidget = 2)
expect_equal(valToValid, 0)
# edit myData
data2 <- readAntares(areas = "all", links = "all", showProgress = FALSE)
data1 <- readAntares(areas = "all", links = "all", showProgress = FALSE)
data2$areas[ , LOAD := as.double(LOAD)][area=="c", LOAD := as.double(LOAD +2500.0)]
dataList2 <- list(data1, data2, data1)
expect_equal(dataList2[[2]]$areas[area=="c", LOAD], dataList2[[1]]$areas[area=="c", LOAD] + 2500)
resPlotMap2 <- plotMap(x = dataList2,
refStudy = data1,
mapLayout = ml,
interactive = FALSE,
colAreaVar = "LOAD",
sizeAreaVars = c("LOAD", "WIND", "SOLAR"))
expect_true("htmlwidget" %in% class(resPlotMap2))
valToValid <- .getDataFromPlotMap(area = "c",
time = "sam. 05 mai 2018<br/>17:00",
variable = "LOAD",
htmlPlotMap = resPlotMap2,
idWidget = 2)
expect_equal(valToValid, 2500)
})

# test_that("plotMap, interactive, x and refStudy are antaresDataList", {
# dta <- readAntares(areas = "all", links = "all", showProgress = FALSE)
Expand Down
20 changes: 10 additions & 10 deletions tests/testthat/test-plotThermalGroupCapacities.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# context("plotThermalGroupCapacities")
#
# test_that("plotThermalGroupCapacities", {
# opts <- setSimulationPath(studyPath)
# GG <- plotThermalGroupCapacities( data = thermalGroupCapacities(opts))
#
# expect_true("htmlwidget" %in% class(GG))
#
# })
#
context("plotThermalGroupCapacities")

test_that("plotThermalGroupCapacities", {
opts <- setSimulationPath(studyPath)
GG <- plotThermalGroupCapacities( data = thermalGroupCapacities(opts))

expect_true("htmlwidget" %in% class(GG))

})

Loading

0 comments on commit 71ebb1a

Please sign in to comment.