@@ -30,76 +30,6 @@ async def reset_event_loop():
3030 if not loop .is_closed ():
3131 loop .close ()
3232
33- @pytest .mark .asyncio
34- async def test_extract_and_update_transition_states_invalid_response (reset_event_loop ):
35- """Test handling of invalid JSON response from model client."""
36- session_id = "test_session"
37- user_id = "test_user"
38- step = Step (
39- data_type = "step" ,
40- plan_id = "test_plan" ,
41- action = "test_action" ,
42- agent = "HumanAgent" ,
43- session_id = session_id ,
44- user_id = user_id ,
45- agent_reply = "test_reply" ,
46- )
47- model_client = AsyncMock ()
48- cosmos_mock = MagicMock ()
49-
50- model_client .create .return_value = MagicMock (content = "invalid_json" )
51-
52- with patch (
53- "src.backend.context.cosmos_memory.CosmosBufferedChatCompletionContext" ,
54- cosmos_mock ,
55- ):
56- with pytest .raises (json .JSONDecodeError ):
57- await extract_and_update_transition_states (
58- step = step ,
59- session_id = session_id ,
60- user_id = user_id ,
61- planner_dynamic_or_workflow = "workflow" ,
62- model_client = model_client ,
63- )
64-
65- cosmos_mock .update_step .assert_not_called ()
66-
67- @pytest .mark .asyncio
68- async def test_extract_and_update_transition_states_validation_error (reset_event_loop ):
69- """Test handling of a response missing required fields."""
70- session_id = "test_session"
71- user_id = "test_user"
72- step = Step (
73- data_type = "step" ,
74- plan_id = "test_plan" ,
75- action = "test_action" ,
76- agent = "HumanAgent" ,
77- session_id = session_id ,
78- user_id = user_id ,
79- agent_reply = "test_reply" ,
80- )
81- model_client = AsyncMock ()
82- cosmos_mock = MagicMock ()
83-
84- invalid_response = {
85- "identifiedTargetState" : "state1"
86- } # Missing 'identifiedTargetTransition'
87- model_client .create .return_value = MagicMock (content = json .dumps (invalid_response ))
88-
89- with patch (
90- "src.backend.context.cosmos_memory.CosmosBufferedChatCompletionContext" ,
91- cosmos_mock ,
92- ):
93- with pytest .raises (ValidationError ):
94- await extract_and_update_transition_states (
95- step = step ,
96- session_id = session_id ,
97- user_id = user_id ,
98- planner_dynamic_or_workflow = "workflow" ,
99- model_client = model_client ,
100- )
101-
102- cosmos_mock .update_step .assert_not_called ()
10333
10434def test_step_initialization ():
10535 """Test Step initialization with valid data."""
0 commit comments