[TEST-EDITS] Added Testing Terminology

pull/1147/head
Aksh Parekh 2 weeks ago committed by GitHub
parent 52dbfbfe05
commit 7f3316100c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -151,7 +151,12 @@ async def test_majority_voting_run_asynchronous(mocker):
# Assert majority vote is correct
assert majority_vote is not None
def test_streaming_majority_voting(agent_name: str, chunk: str, is_final: bool):
def test_streaming_majority_voting():
"""
Test the streaming_majority_voting with logging/try-except and assertion.
"""
logs = []
def streaming_callback(agent_name: str, chunk: str, is_final: bool):
# Chunk buffer static per call (reset each session)
if not hasattr(streaming_callback, "_buffer"):
streaming_callback._buffer = ""
@ -165,19 +170,18 @@ def test_streaming_majority_voting(agent_name: str, chunk: str, is_final: bool):
if streaming_callback._buffer_size >= min_chunk_size or is_final:
if streaming_callback._buffer:
print(streaming_callback._buffer, end="", flush=True)
logs.append(streaming_callback._buffer)
streaming_callback._buffer = ""
streaming_callback._buffer_size = 0
if is_final:
print()
load_dotenv()
try:
# Initialize the agent
agent = Agent(
agent_name="Financial-Analysis-Agent",
agent_description="Personal finance advisor agent",
system_prompt=FINANCIAL_AGENT_SYS_PROMPT,
system_prompt="You are a financial analysis agent.", # replaced missing const
max_loops=1,
model_name="gpt-4.1",
dynamic_temperature_enabled=True,
@ -195,7 +199,12 @@ def test_streaming_majority_voting(agent_name: str, chunk: str, is_final: bool):
swarm = MajorityVoting(agents=[agent, agent, agent])
return swarm.run(
result = swarm.run(
"Create a table of super high growth opportunities for AI. I have $40k to invest in ETFs, index funds, and more. Please create a table in markdown.",
streaming_callback=streaming_callback,
)
assert result is not None
except Exception as e:
print("Error in test_streaming_majority_voting:", e)
print("Logs so far:", logs)
raise

Loading…
Cancel
Save