@@ -307,6 +307,7 @@ async def test_create_model_for_tenant_success_llm():
307307 "base_url" : "http://localhost:8000" ,
308308 "model_type" : "llm" ,
309309 }
310+ model_data ['ssl_verify' ] = False
310311
311312 await svc .create_model_for_tenant (user_id , tenant_id , model_data )
312313
@@ -316,6 +317,32 @@ async def test_create_model_for_tenant_success_llm():
316317 assert mock_create .call_count == 1
317318
318319
320+ @pytest .mark .asyncio
321+ async def test_create_model_for_tenant_open_router_disables_ssl ():
322+ """When base_url contains 'open/router' ssl_verify should be set to False."""
323+ svc = import_svc ()
324+
325+ with mock .patch .object (svc , "get_model_by_display_name" , return_value = None ), \
326+ mock .patch .object (svc , "create_model_record" ) as mock_create , \
327+ mock .patch .object (svc , "split_repo_name" , return_value = ("modelengine" , "m" )):
328+
329+ user_id = "u1"
330+ tenant_id = "t1"
331+ model_data = {
332+ "model_name" : "modelengine/m" ,
333+ "display_name" : None ,
334+ "base_url" : "https://api.example.com/open/router/v1" ,
335+ "model_type" : "llm" ,
336+ }
337+
338+ await svc .create_model_for_tenant (user_id , tenant_id , model_data )
339+
340+ # Ensure a single record created and ssl_verify was disabled
341+ assert mock_create .call_count == 1
342+ create_args = mock_create .call_args [0 ][0 ]
343+ assert create_args ["ssl_verify" ] is False
344+
345+
319346@pytest .mark .asyncio
320347async def test_create_model_for_tenant_conflict_raises ():
321348 svc = import_svc ()
@@ -459,7 +486,7 @@ async def test_create_model_for_tenant_multi_embedding_sets_default_chunk_batch(
459486 mock_dim .assert_awaited_once ()
460487 # Should create two records: multi_embedding and its embedding variant
461488 assert mock_create .call_count == 2
462-
489+
463490 # Verify chunk_batch was set to 10 for both records
464491 create_calls = mock_create .call_args_list
465492 # First call is for multi_embedding
@@ -519,7 +546,7 @@ async def test_batch_create_models_for_tenant_other_provider():
519546 if not hasattr (svc .ProviderEnum , 'MODELENGINE' ):
520547 modelengine_item = _EnumItem ("modelengine" )
521548 svc .ProviderEnum .MODELENGINE = modelengine_item
522-
549+
523550 with mock .patch .object (svc , "get_models_by_tenant_factory_type" , return_value = []), \
524551 mock .patch .object (svc , "delete_model_record" ), \
525552 mock .patch .object (svc , "split_repo_name" , return_value = ("openai" , "gpt-4" )), \
@@ -529,7 +556,7 @@ async def test_batch_create_models_for_tenant_other_provider():
529556 mock .patch .object (svc , "create_model_record" , return_value = True ):
530557
531558 await svc .batch_create_models_for_tenant ("u1" , "t1" , batch_payload )
532-
559+
533560 # Verify prepare_model_dict was called with empty model_url for non-Silicon/ModelEngine provider
534561 call_args = svc .prepare_model_dict .call_args
535562 assert call_args [1 ]["model_url" ] == "" # Should be empty for other providers
@@ -618,7 +645,7 @@ def get_by_display(display_name, tenant_id):
618645 update_calls = [call for call in mock_update .call_args_list if call [0 ][0 ] == "id1" ]
619646 if update_calls :
620647 assert update_calls [0 ][0 ][1 ] == {"max_tokens" : 8192 }
621-
648+
622649 # Should NOT update model2 (max_tokens same) or model3 (new max_tokens is None)
623650 # Verify model2 and model3 were not updated
624651 model2_calls = [call for call in mock_update .call_args_list if call [0 ][0 ] == "id2" ]
0 commit comments