@@ -250,6 +250,17 @@ def test_duplicated_worker_queue(mock_settings):
250
250
("RESOURCE_JWT_USER_ID" , " eda " , "eda" ),
251
251
("RESOURCE_JWT_USER_ID" , ["eda" ], ImproperlyConfigured ),
252
252
("MQ_TLS" , True , True ),
253
+ ("MQ_TLS" , False , False ),
254
+ ("MQ_TLS" , None , None ),
255
+ ("MQ_TLS" , "true" , True ),
256
+ ("MQ_TLS" , "True" , True ),
257
+ ("MQ_TLS" , "false" , False ),
258
+ ("MQ_TLS" , "False" , False ),
259
+ ("MQ_TLS" , "yes" , True ),
260
+ ("MQ_TLS" , "no" , False ),
261
+ ("MQ_TLS" , "1" , True ),
262
+ ("MQ_TLS" , "0" , False ),
263
+ ("MQ_TLS" , "" , False ),
253
264
],
254
265
)
255
266
def test_types (mock_settings , name , value , expected ):
@@ -264,10 +275,10 @@ def test_types(mock_settings, name, value, expected):
264
275
265
276
def test_optional_type_exception_msg (mock_settings ):
266
277
"""Test exception message when an optional type error occurs."""
267
- mock_settings ["MQ_TLS" ] = "true"
278
+ mock_settings ["MQ_TLS" ] = 123 # Use invalid type instead of string
268
279
with pytest .raises (
269
280
ImproperlyConfigured ,
270
- match = "MQ_TLS setting must be a bool or None" ,
281
+ match = "MQ_TLS setting must be a bool or str or None" ,
271
282
):
272
283
post_loading (mock_settings )
273
284
@@ -285,3 +296,46 @@ def test_union_type_exception_msg(mock_settings):
285
296
def test_allow_local_resource_management (mock_settings ):
286
297
# default is False
287
298
assert mock_settings .ALLOW_LOCAL_RESOURCE_MANAGEMENT is False
299
+
300
+
301
+ @pytest .mark .parametrize (
302
+ ("mq_tls_value" , "expected_redis_tls" , "expected_ssl_param" ),
303
+ [
304
+ # Boolean values
305
+ (True , True , True ),
306
+ (False , False , False ),
307
+ (
308
+ None ,
309
+ None ,
310
+ False ,
311
+ ), # None should result in SSL=False (fallback logic)
312
+ # String values that should be converted to True
313
+ ("true" , True , True ),
314
+ ("True" , True , True ),
315
+ ("yes" , True , True ),
316
+ ("Yes" , True , True ),
317
+ ("1" , True , True ),
318
+ # String values that should be converted to False
319
+ ("false" , False , False ),
320
+ ("False" , False , False ),
321
+ ("no" , False , False ),
322
+ ("No" , False , False ),
323
+ ("0" , False , False ),
324
+ ("" , False , False ),
325
+ ("anything" , False , False ),
326
+ ],
327
+ )
328
+ def test_mq_tls_conversion_and_redis_ssl (
329
+ mock_settings , mq_tls_value , expected_redis_tls , expected_ssl_param
330
+ ):
331
+ """Test MQ_TLS setting conversion to REDIS_TLS and SSL parameter."""
332
+ mock_settings .MQ_TLS = mq_tls_value
333
+
334
+ post_loading (mock_settings )
335
+
336
+ # Check that MQ_TLS was properly converted to REDIS_TLS
337
+ assert mock_settings .REDIS_TLS == expected_redis_tls
338
+
339
+ # Check that the Redis queue configuration uses the correct SSL parameter
340
+ queues = get_rq_queues (mock_settings )
341
+ assert queues ["default" ]["SSL" ] == expected_ssl_param
0 commit comments