Skip to content

Commit

Permalink
fix some tests with new study test 870
Browse files Browse the repository at this point in the history
  • Loading branch information
BERTHET Clement (Externe) committed Dec 11, 2023
1 parent 7755082 commit e35840a
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 24 deletions.
66 changes: 51 additions & 15 deletions tests/testthat/test-readBindingConstraints.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,53 @@
test_that("readBindingConstraint", {
context("bindingConstraints")

# >= v710 ----
opts <- setSimulationPath(studyPathS, 0)

test_that("returns an object of class 'bindingConstraints'", {
constraints <- readBindingConstraints(opts)
expect_is(constraints, "bindingConstraints")
})

test_that("summary.bindingConstraints",{
constraints <- readBindingConstraints(opts)
sumConstraints <- summary(constraints)
expect_is(sumConstraints, "data.frame")
expect_true(all(c("enabled", "timeStep", "equation") %in%
names(sumConstraints)))
})


test_that("Both operator",{
constraints <- readBindingConstraints(opts)
constraints[[1]]$operator <- "both"
sumConstraints <- summary(constraints)
expect_is(sumConstraints, "data.frame")
expect_true(all(c("enabled", "timeStep", "equation") %in%
names(sumConstraints)))
})

##delete study ----
#unlink(studyPathS, recursive = TRUE)

# >= v800 ----
#
opts <- antaresRead::setSimulationPath(studyPathSV8[1], "input")

test_that("test if exist data value file", {
bc <- antaresRead::readBindingConstraints(opts = opts)

# test class object return
testthat::expect_equal(class(bc), "bindingConstraints")

names_bc_test <- paste0(names(bc), ".txt")
path_test_bc <- paste0(file.path(opts$inputPath, "bindingconstraints", names_bc_test))

# test for versions v710 v800 v850
all_path_studies <- c(studyPathS, studyPathSV8)
sapply(all_path_studies, function(study) {
opts <- antaresRead::setSimulationPath(study, "input")

bc <- antaresRead::readBindingConstraints(opts = opts)
# test class object return
testthat::expect_equal(class(bc), "bindingConstraints")

names_bc_test <- paste0(names(bc), ".txt")
path_test_bc <- paste0(file.path(opts$inputPath, "bindingconstraints", names_bc_test))
# test if values files exists
testthat::expect_true(all(unlist(lapply(path_test_bc, file.exists))))
})
# test if values files exists
testthat::expect_true(all(unlist(lapply(path_test_bc, file.exists))))
})


# >= v870 ----
#


10 changes: 6 additions & 4 deletions tests/testthat/test-readClusterDesc.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# read study ----
# latest version
path_study_test <- grep(pattern = "87", x = studyPathSV8, value = TRUE)
opts_study_test <- setSimulationPath(path_study_test, simulation = "input")

## v860 ----

path_study_test <- grep(pattern = "86", x = studyPathSV8, value = TRUE)
opts_study_test <- setSimulationPath(path_study_test, simulation = "input")

test_that("test read cluster st-storage v860", {

# function setSimulationPath() provide areas names with st-storage clusters
Expand All @@ -14,5 +15,6 @@ test_that("test read cluster st-storage v860", {

# tests
testthat::expect_true("data.table" %in% class(input_st))
testthat::expect_true(areas_st %in% unique(readClusterSTDesc()$area))
testthat::expect_true(all(
areas_st %in% unique(readClusterSTDesc()$area)))
})
10 changes: 5 additions & 5 deletions tests/testthat/test-readInputTS.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Copyright © 2016 RTE Réseau de transport d’électricité


# v710----
# >= v710----
context("Function readInputTS")
sapply(studyPathS, function(studyPath){

Expand Down Expand Up @@ -125,12 +125,12 @@ test_that("readInputTs must work if we change opts$timeIdMin and opts$timeIdMax"
}
})


# v860----

path_study_test <- grep(pattern = "86", x = studyPathSV8, value = TRUE)
# read latest version study
path_study_test <- grep(pattern = "87", x = studyPathSV8, value = TRUE)
opts_study_test <- setSimulationPath(path_study_test, simulation = "input")

# >= v860----

test_that("readInputTs mingen file v860", {

# to read 8760
Expand Down

0 comments on commit e35840a

Please sign in to comment.