mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
test(guardrails): assert 400 on blocked content in zero-cost tests
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
56995e13c2
commit
92df083b4f
3 changed files with 6 additions and 3 deletions
|
|
@ -307,12 +307,13 @@ class TestEUAIActPerformance:
|
|||
monkeypatch.setattr(httpx.AsyncClient, "send", _no_network)
|
||||
monkeypatch.setattr(httpx.Client, "send", _no_network)
|
||||
|
||||
with pytest.raises(HTTPException, match="Content blocked: eu_ai_act_article"):
|
||||
with pytest.raises(HTTPException, match="Content blocked: eu_ai_act_article") as exc_info:
|
||||
await content_filter_guardrail.apply_guardrail(
|
||||
inputs={"texts": [sentence]},
|
||||
request_data=request_data,
|
||||
input_type="request",
|
||||
)
|
||||
assert exc_info.value.status_code == 400
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -540,12 +540,13 @@ class TestMASEdgeCases:
|
|||
monkeypatch.setattr(httpx.AsyncClient, "send", _no_network)
|
||||
monkeypatch.setattr(httpx.Client, "send", _no_network)
|
||||
|
||||
with pytest.raises(HTTPException, match="Content blocked: sg_mas_human_oversight"):
|
||||
with pytest.raises(HTTPException, match="Content blocked: sg_mas_human_oversight") as exc_info:
|
||||
await oversight_guardrail.apply_guardrail(
|
||||
inputs={"texts": [sentence]},
|
||||
request_data=request_data,
|
||||
input_type="request",
|
||||
)
|
||||
assert exc_info.value.status_code == 400
|
||||
|
||||
|
||||
class TestMASPerformance:
|
||||
|
|
|
|||
|
|
@ -576,12 +576,13 @@ class TestSGPDPAEdgeCases:
|
|||
monkeypatch.setattr(httpx.AsyncClient, "send", _no_network)
|
||||
monkeypatch.setattr(httpx.Client, "send", _no_network)
|
||||
|
||||
with pytest.raises(HTTPException, match="Content blocked: sg_pdpa_personal_identifiers"):
|
||||
with pytest.raises(HTTPException, match="Content blocked: sg_pdpa_personal_identifiers") as exc_info:
|
||||
await personal_identifiers_guardrail.apply_guardrail(
|
||||
inputs={"texts": [sentence]},
|
||||
request_data=request_data,
|
||||
input_type="request",
|
||||
)
|
||||
assert exc_info.value.status_code == 400
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_multiple_violations(self, personal_identifiers_guardrail):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue