Add test_stream_agent.py
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
from stream_agent import StreamingAIAgent
|
||||||
|
|
||||||
|
|
||||||
|
def test_stream_returns_chunks(monkeypatch):
|
||||||
|
monkeypatch.delenv("OPENAI_API_KEY", raising=False)
|
||||||
|
agent = StreamingAIAgent()
|
||||||
|
|
||||||
|
chunks = list(agent.stream("test question"))
|
||||||
|
|
||||||
|
assert len(chunks) > 3
|
||||||
|
assert "".join(chunks).strip()
|
||||||
|
|
||||||
|
|
||||||
|
def test_invoke_matches_stream(monkeypatch):
|
||||||
|
monkeypatch.delenv("OPENAI_API_KEY", raising=False)
|
||||||
|
agent = StreamingAIAgent()
|
||||||
|
|
||||||
|
assert agent.invoke("hello") == "".join(agent.stream("hello"))
|
||||||
Reference in New Issue
Block a user