diff --git a/tests/testthat/test-CreateInputsModel.R b/tests/testthat/test-CreateInputsModel.R index 94d5363e0012292dd87a5701da0a089b74d194b0..4622038f1b169fe6e7352984f92559ebc5f0af0b 100644 --- a/tests/testthat/test-CreateInputsModel.R +++ b/tests/testthat/test-CreateInputsModel.R @@ -183,23 +183,19 @@ test_that("negative observed flow on catchment should throw error", { "GRiwrmInputsModel") }) +# data set up +e <- setupRunModel(runInputsModel = FALSE) +# variables are copied from environment 'e' to the current environment +# https://stackoverflow.com/questions/9965577/r-copy-move-one-environment-to-another +for(x in ls(e)) assign(x, get(x, e)) + test_that("Ungauged node should inherits its FUN_MOD from the downstream gauged node", { - data(Severn) - nodes <- - Severn$BasinsInfo[, c("gauge_id", "downstream_id", "distance_downstream", "area")] - nodes$model <- "RunModel_GR4J" + nodes$model[nodes$gauge_id == "54032"] <- "Ungauged" griwrmV05 <- CreateGRiwrm( nodes, list(id = "gauge_id", down = "downstream_id", length = "distance_downstream") ) - BasinsObs <- Severn$BasinsObs - DatesR <- BasinsObs[[1]]$DatesR - PrecipTot <- cbind(sapply(BasinsObs, function(x) {x$precipitation})) - PotEvapTot <- cbind(sapply(BasinsObs, function(x) {x$peti})) - Precip <- ConvertMeteoSD(griwrmV05, PrecipTot) - PotEvap <- ConvertMeteoSD(griwrmV05, PotEvapTot) - Qobs <- cbind(sapply(BasinsObs, function(x) {x$discharge_spec})) IM <- suppressWarnings( CreateInputsModel(griwrmV05, DatesR, Precip, PotEvap, Qobs) )