mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
test(rust): account for nonblocking callback export
This commit is contained in:
parent
a89e61e932
commit
9a99aaddcd
1 changed files with 6 additions and 7 deletions
|
|
@ -113,7 +113,9 @@ async def test_generic_api_logger_exports_provider_failure_over_http(route: Rout
|
|||
async def test_generic_guardrail_logging_only_verdict_is_exported_over_http(
|
||||
route: Route, provider: RecordingServer, verdict: ResponseSpec, expected_status: str
|
||||
) -> None:
|
||||
provider.expected_requests = 3
|
||||
# Async OCR intentionally dispatches both sync and async success callbacks;
|
||||
# the non-blocking sync exporter may finish before or after this assertion.
|
||||
provider.expected_requests = None
|
||||
provider.enqueue(ResponseSpec(body=route.provider_response))
|
||||
provider.enqueue(verdict)
|
||||
provider.enqueue(ResponseSpec(body={}))
|
||||
|
|
@ -130,14 +132,14 @@ async def test_generic_guardrail_logging_only_verdict_is_exported_over_http(
|
|||
await recorder.wait_for_async("async_log_success_event")
|
||||
await drain_logging()
|
||||
await provider.wait_for_requests(3)
|
||||
assert len(provider.requests) == 3
|
||||
|
||||
scan: Final = provider.requests[1]
|
||||
assert scan.path == "/beta/litellm_basic_guardrail_api"
|
||||
assert scan.body["input_type"] == route.logging_only_scan[0]
|
||||
assert scan.body["texts"] == list(route.logging_only_scan[1])
|
||||
assert provider.requests[2].path == "/logs"
|
||||
payload: Final = provider.requests[2].body
|
||||
exports: Final = [request for request in provider.requests if request.path == "/logs"]
|
||||
assert len(exports) in (1, 2)
|
||||
payload: Final = exports[0].body
|
||||
assert payload["status"] == "success"
|
||||
assert [(entry["guardrail_name"], entry["guardrail_status"]) for entry in payload["guardrail_information"]] == [
|
||||
("http-review", expected_status)
|
||||
|
|
@ -148,9 +150,6 @@ async def test_generic_guardrail_logging_only_verdict_is_exported_over_http(
|
|||
else:
|
||||
assert response["content"][0]["text"] == route.response_text
|
||||
assert "guardrails" not in provider.requests[0].body
|
||||
# The async OCR callback may finish its transport cleanup after the test body.
|
||||
# Request cardinality was verified above, before releasing the fixture.
|
||||
provider.expected_requests = None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue