@@ -81,9 +81,11 @@ test_that("testing read parameters", {
8181 # Create input file
8282 path = " test.temp"
8383 create_dir_not_exist(path )
84- expect_silent (params <- read_params(path = " params-test.json" ,
84+ expect_warning (params <- read_params(path = " params-test.json" ,
8585 template_path = " params-test.json.template" ,
86- train_models = TRUE , make_predictions = TRUE ))
86+ train_models = TRUE , make_predictions = TRUE ),
87+ " gurobi solver was requested but license information was not available"
88+ )
8789 unlink(path , recursive = TRUE )
8890
8991
@@ -125,7 +127,7 @@ test_that("testing read parameters", {
125127
126128 expect_true(all(params $ taus == TAUS ))
127129 expect_true(params $ lambda == LAMBDA )
128- expect_true(params $ lp_solver == LP_SOLVER )
130+ expect_true(params $ lp_solver == " glpk " )
129131 expect_true(params $ lag_pad == LAG_PAD )
130132
131133 expect_true(params $ num_col == " num" )
@@ -148,6 +150,44 @@ test_that("testing read parameters", {
148150 expect_silent(file.remove(" params-test.json" ))
149151})
150152
153+ test_that(" lp_solver selection works" , {
154+ # GLPK selected explicitly.
155+ path = " test.temp"
156+ create_dir_not_exist(path )
157+ expect_silent(params <- read_params(path = " params-glpk_direct.json" ,
158+ template_path = " params-glpk_direct.json.template" ,
159+ train_models = TRUE , make_predictions = TRUE ))
160+ expect_true(params $ lp_solver == " glpk" )
161+ expect_silent(file.remove(" params-glpk_direct.json" ))
162+
163+ # gurobi selected explicitly, but without gurobi params subsection
164+ expect_warning(params <- read_params(path = " params-grb_noparams.json" ,
165+ template_path = " params-grb_noparams.json.template" ,
166+ train_models = TRUE , make_predictions = TRUE ),
167+ " gurobi solver was requested but license information was not available"
168+ )
169+ expect_true(params $ lp_solver == " glpk" )
170+ expect_silent(file.remove(" params-grb_noparams.json" ))
171+
172+ # gurobi selected explicitly, with gurobi params subsection, but without license information
173+ expect_warning(params <- read_params(path = " params-grb_notallparams.json" ,
174+ template_path = " params-grb_notallparams.json.template" ,
175+ train_models = TRUE , make_predictions = TRUE ),
176+ " gurobi solver was requested but license information was not available"
177+ )
178+ expect_true(params $ lp_solver == " glpk" )
179+ expect_silent(file.remove(" params-grb_notallparams.json" ))
180+
181+ # gurobi selected explicitly
182+ expect_silent(params <- read_params(path = " params-grb.json" ,
183+ template_path = " params-grb.json.template" ,
184+ train_models = TRUE , make_predictions = TRUE ))
185+ expect_true(params $ lp_solver == " gurobi" )
186+ expect_silent(file.remove(" params-grb.json" ))
187+
188+ unlink(path , recursive = TRUE )
189+ })
190+
151191test_that(" validity_checks alerts appropriately" , {
152192 time_value = as.Date(c(" 2022-01-01" , " 2022-01-02" , " 2022-01-03" ))
153193 issue_date = as.Date(c(" 2022-01-05" , " 2022-01-05" , " 2022-01-05" ))
0 commit comments