Skip to content

Commit

Permalink
fix test thermal + add test RES
Browse files Browse the repository at this point in the history
  • Loading branch information
berthetclement committed Jun 4, 2024
1 parent 53daa93 commit 74be4b1
Showing 1 changed file with 39 additions and 11 deletions.
50 changes: 39 additions & 11 deletions tests/testthat/test-readInputClusters.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,50 @@ sapply(studyPathS, function(studyPath){

test_that("Thermal availabilities importation works", {
# read /series files (default)
input <- readInputThermal(clusters = "peak_must_run_partial", showProgress = FALSE)
input <- readInputThermal(clusters = "peak_must_run_partial",
showProgress = FALSE)
expect_is(input, "antaresDataTable")
expect_gt(nrow(input), 0)
expect_equal(nrow(input) %% (24 * 7 * nweeks), 0)
})

test_that("Thermal modulation importation works", {
input <- readInputThermal(clusters = "peak_must_run_partial", thermalModulation = TRUE, showProgress = FALSE)
# read /series + /prepro/modulation.txt
input <- readInputThermal(clusters = "peak_must_run_partial",
thermalModulation = TRUE,
showProgress = FALSE)
expect_is(input, "antaresDataList")
expect_is(input$thermalModulation, "antaresDataTable")
expect_gt(nrow(input$thermalModulation), 0)
expect_equal(nrow(input$thermalModulation) %% (24 * 7 * nweeks), 0)
})

test_that("Thermal data importation works", {
input <- readInputThermal(clusters = "peak_must_run_partial", thermalData = TRUE, showProgress = FALSE, timeStep = 'daily')
# read /series + /prepro/data.txt
input <- readInputThermal(clusters = "peak_must_run_partial",
thermalData = TRUE,
showProgress = FALSE)
expect_is(input, "antaresDataList")
expect_is(input$thermalModulation, "antaresDataTable")
expect_gt(nrow(input$thermalModulation), 0)
expect_equal(nrow(input$thermalModulation) %% (24 * 7 * nweeks), 0)
expect_is(input$thermalData, "antaresDataTable")
expect_gt(nrow(input$thermalData), 0)
expect_equal(nrow(input$thermalData) %% (24 * 7 * nweeks), 0)
})

test_that("Wrong area", {
expect_error(readInputThermal(areas = "BAD_AREA", clusters = "peak_must_run_partial"),
expect_error(readInputThermal(areas = "BAD_AREA",
clusters = "peak_must_run_partial"),
regexp = "areas are not available")
})

test_that("Wrong cluster", {
expect_error(readInputThermal(areas = "all", clusters = "BAD_CLUSTER"),
expect_error(readInputThermal(areas = "all",
clusters = "BAD_CLUSTER"),
regexp = "clusters are not available")
})

test_that("No thermal data selected", {
expect_error(readInputThermal(clusters = "peak_must_run_partial", thermalAvailabilities = FALSE),
expect_error(readInputThermal(clusters = "peak_must_run_partial",
thermalAvailabilities = FALSE),
regexp = "one type of data should be selected")
})

Expand All @@ -58,8 +68,26 @@ test_that("test reading TS RES", {
path_study_test <- grep(pattern = "87", x = studyPathSV8, value = TRUE)
setSimulationPath(path_study_test, simulation = "input")

toto= readInputRES(clusters = "at_res_1")
res_clust_properties <- readClusterResDesc()

test_that("read one cluster", {
# read /series files (default)
input <- readInputRES(areas = "all",
clusters = unique(res_clust_properties$cluster)[1])
expect_is(input, "antaresDataTable")
expect_gt(nrow(input), 0)
expect_equal(nrow(input) %% (24 * 7 * nweeks), 0)
})

toto = readInputThermal(clusters = "at_gas")
test_that("read various clusters", {
nb_cluster <- length(unique(res_clust_properties$cluster))
# read /series files (default)
input <- readInputRES(areas = "all",
clusters = unique(res_clust_properties$cluster))
expect_is(input, "antaresDataTable")
expect_gt(nrow(input), 0)
expect_equal(nrow(input) %% (24 * 7 * nweeks), 0)
})


})

0 comments on commit 74be4b1

Please sign in to comment.