From 74be4b18ff14899a8387d2a9afa0d06d6b54488b Mon Sep 17 00:00:00 2001 From: berthetclement Date: Tue, 4 Jun 2024 15:38:00 +0200 Subject: [PATCH] fix test thermal + add test RES --- tests/testthat/test-readInputClusters.R | 50 +++++++++++++++++++------ 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/tests/testthat/test-readInputClusters.R b/tests/testthat/test-readInputClusters.R index 30a968c4..7d6c7310 100644 --- a/tests/testthat/test-readInputClusters.R +++ b/tests/testthat/test-readInputClusters.R @@ -10,14 +10,18 @@ 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) @@ -25,25 +29,31 @@ sapply(studyPathS, function(studyPath){ }) 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") }) @@ -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) + }) + })