1919sys .modules ["azure.monitor.events.extension" ] = MagicMock ()
2020
2121
22- from src .backend .event_utils import track_event_if_configured
2322from 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 ---
3333from src .backend .agents .group_chat_manager import GroupChatManager
3434from src .backend .models .messages import (
@@ -43,7 +43,7 @@ def dummy_agent_instantiation_context():
4343 BAgentType ,
4444)
4545from 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 ---
4949class 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 ---
115111async 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 ---
152149class 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
347344async 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" ,
0 commit comments