Skip to content

Commit

Permalink
add api block
Browse files Browse the repository at this point in the history
  • Loading branch information
BERTHET Clement (Externe) committed Nov 6, 2023
1 parent c16b1fe commit a0dc991
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
30 changes: 26 additions & 4 deletions R/thematic_trimming.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,35 @@
#' }
getThematicTrimming <- function(opts = simOptions()){
stopifnot(inherits(opts, "simOptions"))
stopifnot(opts$antaresVersion>=800)

##
# API bloc
##
if(antaresRead:::is_api_study(opts = opts)){
# use endpoint from API "Get thematic trimming config"
endpoint_to_use <- "config/thematictrimming/form"
endpoint_to_use <- file.path(opts$study_id,
endpoint_to_use)

Check warning on line 36 in R/thematic_trimming.R

View check run for this annotation

Codecov / codecov/patch

R/thematic_trimming.R#L34-L36

Added lines #L34 - L36 were not covered by tests

thematic_vars <- api_get(opts = opts,
endpoint = endpoint_to_use)

Check warning on line 39 in R/thematic_trimming.R

View check run for this annotation

Codecov / codecov/patch

R/thematic_trimming.R#L38-L39

Added lines #L38 - L39 were not covered by tests

return(thematic_vars)

Check warning on line 41 in R/thematic_trimming.R

View check run for this annotation

Codecov / codecov/patch

R/thematic_trimming.R#L41

Added line #L41 was not covered by tests
}

##
# Desktop
##

# read study to update opts meta data
opts_study <- setSimulationPath(opts$studyPath,
simulation = "input")
suppressWarnings(
opts_study <- setSimulationPath(opts$studyPath,
simulation = "input")
)

# use global referentiel
ref_list_vars_thematic <- antaresRead:::pkgEnv$thematic
# use private referentiel
ref_list_vars_thematic <- pkgEnv$thematic

# filter vars with version
ref_list_vars_thematic <- ref_list_vars_thematic[version<=opts_study$antaresVersion,]
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-thematic_timming.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
path_study_test <- grep(pattern = "86", x = studyPathSV8, value = TRUE)
opts_study_test <- setSimulationPath(path_study_test, simulation = "input")

# NOTES :
# In this study test there is no section [selection variables]

# test_that("Empty selection variables", {
# # template study 860 as no section
Expand Down

0 comments on commit a0dc991

Please sign in to comment.