ajuste no contas

This commit is contained in:
T3782834
2026-09-01 11:24:03 -03:00
parent 9ed4782f9d
commit 397b831fd3
428 changed files with 2294 additions and 4648 deletions

View File

@@ -0,0 +1,47 @@
from __future__ import annotations
import pytest
import agent_framework.guardrails.framework_llm_client as module
class _OwnedLLM:
def __init__(self):
self.closed = False
async def ainvoke(self, *args, **kwargs):
return '{"allowed": true, "reason": ""}'
async def aclose(self):
self.closed = True
@pytest.mark.asyncio
async def test_temporary_guardrail_provider_is_closed_inside_owning_event_loop(monkeypatch):
llm = _OwnedLLM()
monkeypatch.setattr(module, '_ensure_framework_llm', lambda value: llm)
monkeypatch.setenv('USE_MOCK_LLM', 'false')
result = await module.classify_with_framework_llm(
None,
'AOFERTA',
{'text': 'Posso ajudar?', 'context': {}},
)
assert result['allowed'] is True
assert llm.closed is True
@pytest.mark.asyncio
async def test_caller_owned_guardrail_provider_is_not_closed(monkeypatch):
llm = _OwnedLLM()
monkeypatch.setenv('USE_MOCK_LLM', 'false')
result = await module.classify_with_framework_llm(
llm,
'AOFERTA',
{'text': 'Posso ajudar?', 'context': {}},
)
assert result['allowed'] is True
assert llm.closed is False