@@ -218,7 +218,13 @@ MOI.Utilities.@model(
218
218
(MOI. VectorAffineFunction, MOI. VectorQuadraticFunction)
219
219
)
220
220
221
- function unsupported_constraint_attribute ()
221
+ struct AttributeNotAllowed <: MOI.AbstractConstraintAttribute end
222
+
223
+ function MOI. supports (:: MOI.ModelLike , :: AttributeNotAllowed , :: Type{<:MOI.Bridges.Constraint.SplitIntervalBridge} )
224
+ return true
225
+ end
226
+
227
+ function test_unsupported_constraint_attribute ()
222
228
mock = MOI. Utilities. MockOptimizer (NoIntervalModel {Float64} ())
223
229
bridged_mock = MOI. Bridges. Constraint. LessToGreater {Float64} (
224
230
MOI. Bridges. Constraint. SplitInterval {Float64} (mock),
@@ -231,22 +237,27 @@ function unsupported_constraint_attribute()
231
237
MOI. LessThan{Float64},
232
238
}
233
239
attr = MOI. Test. UnknownConstraintAttribute ()
234
- err = ArgumentError (
235
- " Bridge of type `$(bridge) ` does not support accessing " *
240
+ message (action) =
241
+ " Bridge of type `$(nameof ( bridge)) ` does not support $action " *
236
242
" the attribute `$attr `. If you encountered this error " *
237
243
" unexpectedly, it probably means your model has been " *
238
244
" reformulated using the bridge, and you are attempting to query " *
239
245
" an attribute that we haven't implemented yet for this bridge. " *
240
246
" Please open an issue at https://github.com/jump-dev/MathOptInterface.jl/issues/new " *
241
247
" and provide a reproducible example explaining what you were " *
242
- " trying to do." ,
243
- )
248
+ " trying to do."
244
249
x = MOI. add_variable (bridged_mock)
245
250
ci = MOI. add_constraint (bridged_mock, x, MOI. Interval (0.0 , 1.0 ))
246
251
@test ! MOI. Bridges. is_bridged (bridged_mock, ci)
247
252
@test MOI. Bridges. is_bridged (bridged_mock. model, ci)
248
253
@test ! MOI. supports (bridged_mock, attr, typeof (ci))
254
+ err = ArgumentError (message (" accessing" ))
249
255
@test_throws err MOI. get (bridged_mock, attr, ci)
256
+ err = MOI. UnsupportedAttribute (attr, message (" setting a value for" ))
257
+ @test_throws err MOI. set (bridged_mock, attr, ci, 1 )
258
+ attr = AttributeNotAllowed ()
259
+ err = MOI. SetAttributeNotAllowed (attr, message (" setting a value for" ))
260
+ @test_throws err MOI. set (bridged_mock, attr, ci, 1 )
250
261
return
251
262
end
252
263
0 commit comments