@@ -476,176 +476,3 @@ def test_create_file_for_each_model(
476
476
openai_call_found = True
477
477
break
478
478
assert openai_call_found , "OpenAI call not found with expected parameters"
479
-
480
-
481
- def test_get_files_provider_config_vertex_ai_with_model_list ():
482
- """
483
- Test that get_files_provider_config correctly extracts Vertex AI config from model_list
484
- This test verifies the fix for the proxy file upload issue
485
- """
486
- from litellm .proxy .openai_files_endpoints .files_endpoints import get_files_provider_config , files_config
487
- from litellm .proxy .proxy_server import proxy_config
488
-
489
- # Mock the proxy_config with a model_list containing Vertex AI configuration
490
- mock_config = {
491
- 'model_list' : [
492
- {
493
- 'model_name' : 'gemini-2.5-flash' ,
494
- 'litellm_params' : {
495
- 'model' : 'vertex_ai/gemini-2.5-flash' ,
496
- 'vertex_project' : 'test-project-123' ,
497
- 'vertex_location' : 'us-central1' ,
498
- 'vertex_credentials' : '/path/to/service_account.json'
499
- }
500
- },
501
- {
502
- 'model_name' : 'gpt-3.5-turbo' ,
503
- 'litellm_params' : {
504
- 'model' : 'openai/gpt-3.5-turbo' ,
505
- 'api_key' : 'test-key'
506
- }
507
- }
508
- ]
509
- }
510
-
511
- # Mock proxy_config.config
512
- original_config = getattr (proxy_config , 'config' , None )
513
- proxy_config .config = mock_config
514
-
515
- # Mock files_config to avoid ValueError for non-vertex_ai providers
516
- original_files_config = files_config
517
- import litellm .proxy .openai_files_endpoints .files_endpoints
518
- litellm .proxy .openai_files_endpoints .files_endpoints .files_config = []
519
-
520
- try :
521
- # Test that vertex_ai provider returns the correct config
522
- result = get_files_provider_config ('vertex_ai' )
523
-
524
- assert result is not None , "get_files_provider_config should return config for vertex_ai"
525
- assert result ['vertex_project' ] == 'test-project-123'
526
- assert result ['vertex_location' ] == 'us-central1'
527
- assert result ['vertex_credentials' ] == '/path/to/service_account.json'
528
-
529
- # Test that non-vertex_ai providers still work as before
530
- result_openai = get_files_provider_config ('openai' )
531
- assert result_openai is None # Should return None when files_config is empty
532
-
533
- finally :
534
- # Restore original config
535
- if original_config is not None :
536
- proxy_config .config = original_config
537
- else :
538
- delattr (proxy_config , 'config' )
539
-
540
- # Restore original files_config
541
- litellm .proxy .openai_files_endpoints .files_endpoints .files_config = original_files_config
542
-
543
-
544
- def test_get_files_provider_config_vertex_ai_no_model_list ():
545
- """
546
- Test that get_files_provider_config returns None when no model_list is available
547
- This ensures graceful handling when proxy_config is not properly initialized
548
- """
549
- from litellm .proxy .openai_files_endpoints .files_endpoints import get_files_provider_config
550
- from litellm .proxy .proxy_server import proxy_config
551
-
552
- # Mock proxy_config without model_list
553
- original_config = getattr (proxy_config , 'config' , None )
554
- proxy_config .config = {}
555
-
556
- try :
557
- result = get_files_provider_config ('vertex_ai' )
558
- assert result is None , "get_files_provider_config should return None when no model_list"
559
-
560
- finally :
561
- # Restore original config
562
- if original_config is not None :
563
- proxy_config .config = original_config
564
- else :
565
- delattr (proxy_config , 'config' )
566
-
567
-
568
- def test_get_files_provider_config_vertex_ai_no_vertex_models ():
569
- """
570
- Test that get_files_provider_config returns None when no vertex_ai models are in model_list
571
- This ensures the function handles cases where only non-vertex models are configured
572
- """
573
- from litellm .proxy .openai_files_endpoints .files_endpoints import get_files_provider_config
574
- from litellm .proxy .proxy_server import proxy_config
575
-
576
- # Mock the proxy_config with a model_list containing only non-Vertex AI models
577
- mock_config = {
578
- 'model_list' : [
579
- {
580
- 'model_name' : 'gpt-3.5-turbo' ,
581
- 'litellm_params' : {
582
- 'model' : 'openai/gpt-3.5-turbo' ,
583
- 'api_key' : 'test-key'
584
- }
585
- },
586
- {
587
- 'model_name' : 'claude-3' ,
588
- 'litellm_params' : {
589
- 'model' : 'anthropic/claude-3' ,
590
- 'api_key' : 'test-key'
591
- }
592
- }
593
- ]
594
- }
595
-
596
- # Mock proxy_config.config
597
- original_config = getattr (proxy_config , 'config' , None )
598
- proxy_config .config = mock_config
599
-
600
- try :
601
- result = get_files_provider_config ('vertex_ai' )
602
- assert result is None , "get_files_provider_config should return None when no vertex_ai models in model_list"
603
-
604
- finally :
605
- # Restore original config
606
- if original_config is not None :
607
- proxy_config .config = original_config
608
- else :
609
- delattr (proxy_config , 'config' )
610
-
611
-
612
- def test_get_files_provider_config_vertex_ai_partial_config ():
613
- """
614
- Test that get_files_provider_config handles partial Vertex AI configuration gracefully
615
- This ensures the function works even when some vertex_ai parameters are missing
616
- """
617
- from litellm .proxy .openai_files_endpoints .files_endpoints import get_files_provider_config
618
- from litellm .proxy .proxy_server import proxy_config
619
-
620
- # Mock the proxy_config with partial Vertex AI configuration
621
- mock_config = {
622
- 'model_list' : [
623
- {
624
- 'model_name' : 'gemini-2.5-flash' ,
625
- 'litellm_params' : {
626
- 'model' : 'vertex_ai/gemini-2.5-flash' ,
627
- 'vertex_project' : 'test-project-123' ,
628
- # Missing vertex_location and vertex_credentials
629
- }
630
- }
631
- ]
632
- }
633
-
634
- # Mock proxy_config.config
635
- original_config = getattr (proxy_config , 'config' , None )
636
- proxy_config .config = mock_config
637
-
638
- try :
639
- result = get_files_provider_config ('vertex_ai' )
640
-
641
- assert result is not None , "get_files_provider_config should return config even with partial vertex_ai params"
642
- assert result ['vertex_project' ] == 'test-project-123'
643
- assert 'vertex_location' not in result
644
- assert 'vertex_credentials' not in result
645
-
646
- finally :
647
- # Restore original config
648
- if original_config is not None :
649
- proxy_config .config = original_config
650
- else :
651
- delattr (proxy_config , 'config' )
0 commit comments