Skip to content

Commit 434bb25

Browse files
Testcases
1 parent 3431cd9 commit 434bb25

File tree

6 files changed

+9
-17
lines changed

6 files changed

+9
-17
lines changed

src/backend/tests/agents/test_group_chat_manager.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
sys.modules["azure.monitor.events.extension"] = MagicMock()
2020

2121

22-
from src.backend.event_utils import track_event_if_configured
2322
from autogen_core.base._agent_instantiation import AgentInstantiationContext
2423

2524

@@ -29,6 +28,7 @@ def dummy_agent_instantiation_context():
2928
yield
3029
AgentInstantiationContext.AGENT_INSTANTIATION_CONTEXT_VAR.reset(token)
3130

31+
3232
# --- Import production classes ---
3333
from src.backend.agents.group_chat_manager import GroupChatManager
3434
from src.backend.models.messages import (
@@ -43,7 +43,7 @@ def dummy_agent_instantiation_context():
4343
BAgentType,
4444
)
4545
from autogen_core.base import AgentId, MessageContext
46-
from src.backend.context.cosmos_memory import CosmosBufferedChatCompletionContext
46+
4747

4848
# --- Define a DummyMessageContext that supplies required parameters ---
4949
class DummyMessageContext(MessageContext):
@@ -75,7 +75,6 @@ async def get_plan_by_session(self, session_id: str) -> Plan:
7575
human_clarification_response="Plan feedback",
7676
)
7777

78-
7978
async def get_steps_by_plan(self, plan_id: str) -> list:
8079
step1 = Step.model_construct(
8180
id="step1",
@@ -107,9 +106,6 @@ async def add_plan(self, plan: Plan):
107106
async def update_plan(self, plan: Plan):
108107
pass
109108

110-
async def update_step(self, step: Step):
111-
self.updated_steps.append(step)
112-
113109

114110
# --- Fake send_message for GroupChatManager ---
115111
async def fake_send_message(message, agent_id):
@@ -148,11 +144,12 @@ def group_chat_manager():
148144
manager.send_message = AsyncMock(side_effect=fake_send_message)
149145
return manager, fake_memory
150146

147+
151148
# --- To simulate a missing agent in a step, define a dummy subclass ---
152149
class DummyStepMissingAgent(Step):
153150
@property
154151
def agent(self):
155-
return ""
152+
return ""
156153

157154

158155
# ---------------------- Tests ----------------------
@@ -346,12 +343,13 @@ async def test_execute_step_human_agent(group_chat_manager):
346343
@pytest.mark.asyncio
347344
async def test_execute_step_missing_agent_raises(group_chat_manager):
348345
manager, fake_memory = group_chat_manager
346+
349347
# Create a dummy step using a subclass that forces agent to be an empty string.
350348
class DummyStepMissingAgent(Step):
351349
@property
352350
def agent(self):
353351
return ""
354-
step = DummyStepMissingAgent.model_construct(
352+
DummyStepMissingAgent.model_construct(
355353
id="step_missing",
356354
plan_id="plan1",
357355
action="Do something",

src/backend/tests/agents/test_human.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
# Patch azure module so that event_utils imports correctly.
2121
sys.modules["azure.monitor.events.extension"] = MagicMock()
2222

23-
from src.backend.event_utils import track_event_if_configured
2423
from autogen_core.base._agent_instantiation import AgentInstantiationContext
2524
dummy_runtime = MagicMock()
2625
dummy_agent_id = "dummy_agent_id"

src/backend/tests/agents/test_marketing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
sys.modules["azure.monitor.events.extension"] = MagicMock()
2121

2222
# Import the marketing functions and MarketingAgent from the module.
23-
from autogen_core.components.tools import FunctionTool
2423
from src.backend.agents.marketing import (
2524
create_marketing_campaign,
2625
analyze_market_trends,

src/backend/tests/agents/test_planner.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44
import json
55
import pytest
6-
from unittest.mock import AsyncMock, MagicMock, patch
6+
from unittest.mock import AsyncMock, MagicMock
77

88
# --- Setup environment and module search path ---
99
os.environ["COSMOSDB_ENDPOINT"] = "https://mock-endpoint"
@@ -18,11 +18,7 @@
1818
# Ensure the project root is in sys.path.
1919
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../")))
2020

21-
# --- Patch event tracking to be a no-op ---
2221
from src.backend.event_utils import track_event_if_configured
23-
track_event_if_configured = lambda event, props: None
24-
25-
# --- Patch AgentInstantiationContext to bypass instantiation errors ---
2622
from autogen_core.base._agent_instantiation import AgentInstantiationContext
2723

2824

src/backend/tests/agents/test_procurement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import os
22
import sys
33
import pytest
4-
from datetime import datetime
54
from unittest.mock import MagicMock
65

76
# --- Fake missing Azure modules ---
@@ -138,6 +137,7 @@ async def test_procurement_functions(func, args, expected):
138137
else:
139138
assert result == expected
140139

140+
141141
# --- Test get_procurement_tools ---
142142
def test_get_procurement_tools():
143143
tools = get_procurement_tools()

src/backend/tests/test_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def override_dependencies(monkeypatch):
129129
"src.backend.auth.auth_utils.get_authenticated_user_details",
130130
lambda headers: {"user_principal_id": "mock-user-id"},
131131
)
132-
132+
133133
monkeypatch.setattr(
134134
"src.backend.utils.retrieve_all_agent_tools",
135135
lambda: [{

0 commit comments

Comments
 (0)