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:
mateo 2026-09-07 06:56:48 +00:00
parent 56995e13c2
commit 92df083b4f
3 changed files with 6 additions and 3 deletions

View file

@ -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__":

View file

@ -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:

View file

@ -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):