litellm/tests/batches_tests
Alexsander Hamir 655e04f16c
Fix: apply_guardrail method and improve test isolation (#17555)
* Fix Bedrock guardrail apply_guardrail method and test mocks

Fixed 4 failing tests in the guardrail test suite:

1. BedrockGuardrail.apply_guardrail now returns original texts when guardrail
   allows content but doesn't provide output/outputs fields. Previously returned
   empty list, causing test_bedrock_apply_guardrail_success to fail.

2. Updated test mocks to use correct Bedrock API response format:
   - Changed from 'content' field to 'output' field
   - Fixed nested structure from {'text': {'text': '...'}} to {'text': '...'}
   - Added missing 'output' field in filter test

3. Fixed endpoint test mocks to return GenericGuardrailAPIInputs format:
   - Changed from tuple (List[str], Optional[List[str]]) to dict {'texts': [...]}
   - Updated method call assertions to use 'inputs' parameter correctly

All 12 guardrail tests now pass successfully.

* fix: remove python3-dev from Dockerfile.build_from_pip to avoid Python version conflict

The base image cgr.dev/chainguard/python:latest-dev already includes Python 3.14
and its development tools. Installing python3-dev pulls Python 3.13 packages
which conflict with the existing Python 3.14 installation, causing file
ownership errors during apk install.

* fix: disable callbacks in vertex fine-tuning tests to prevent Datadog logging interference

The test was failing because Datadog logging was making an HTTP POST request
that was being caught by the mock, causing assert_called_once() to fail.
By disabling callbacks during the test, we prevent Datadog from making any
HTTP calls, allowing the mock to only see the Vertex AI API call.

* fix: ensure test isolation in test_logging_non_streaming_request

Add proper cleanup to restore original litellm.callbacks after test execution.
This prevents test interference when running as part of a larger test suite,
where global state pollution was causing async_log_success_event to be
called multiple times instead of once.

Fixes test failure where the test expected async_log_success_event to be
called once but was being called twice due to callbacks from previous tests
not being cleaned up.
2025-12-05 12:59:35 -08:00
..
batch_job_results_furniture.jsonl (feat) Add cost tracking for /batches requests OpenAI (#7384) 2024-12-23 17:47:26 -08:00
batch_small.jsonl [Feat] Add support for Batch API Rate limiting - PR1 adds support for input based rate limits (#16075) 2025-10-29 18:28:52 -07:00
bedrock_batch_completions.jsonl [Feat] Bedrock Batches - Working e2e flow to upload file + create batch (#14518) 2025-09-12 15:37:09 -07:00
conftest.py [Perf] Improvements for Async Success Handler (Logging Callbacks) - Approx +130 RPS (#13905) 2025-08-23 13:13:23 -07:00
openai_batch_completions.jsonl (feat) Add cost tracking for /batches requests OpenAI (#7384) 2024-12-23 17:47:26 -08:00
pathrise-convert-1606954137718.json use pathrise-convert-1606954137718 2025-01-05 14:14:43 -08:00
test_batch_rate_limits.py [Feat] Add support for Batch API Rate limiting - PR1 adds support for input based rate limits (#16075) 2025-10-29 18:28:52 -07:00
test_batches_logging_unit_tests.py Store batch output file id in DB + Store batch file status in DB + (experimental) BATCH API COST TRACKING 2025-06-25 22:41:22 -07:00
test_bedrock_files_and_batches.py [Feat] Bedrock Batches - Add support for custom KMS encryption keys in Bedrock Batch operations (#16662) 2025-11-14 16:00:43 -08:00
test_fine_tuning_api.py Fix: apply_guardrail method and improve test isolation (#17555) 2025-12-05 12:59:35 -08:00
test_hosted_vllm_batches_and_files.py test_hosted_vllm_full_workflow 2025-12-03 19:43:29 -08:00
test_openai_batches_and_files.py new mocked 2025-11-25 17:28:02 +05:30
vertex_batch_completions.jsonl (feat) Add cost tracking for /batches requests OpenAI (#7384) 2024-12-23 17:47:26 -08:00