Skip to content

Commit a3fca70

Browse files
committed
update the test case
1 parent a9cae7e commit a3fca70

1 file changed

Lines changed: 32 additions & 28 deletions

File tree

backend/tests/test_block_generation.py

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def test_run_agent_with_session_does_not_persist_root_block_when_disabled():
1111

1212
with patch("agent.assess_context_or_answer_simple") as mock_preflight, \
1313
patch("agent.run_orchestrator") as mock_orch, \
14-
patch("agent.openai_chat") as mock_chat:
14+
patch("agent.llm_chat") as mock_chat:
1515
mock_preflight.return_value = (True, "")
1616
mock_orch.return_value = [{"title": "Main", "instructions": "test"}]
1717
mock_chat.side_effect = [{"content": "hello", "tool_calls": None}]
@@ -47,7 +47,7 @@ def test_run_agent_with_session_persists_reasoning_summary_in_block_metadata():
4747
session.blocks = [Block(id="parent")]
4848

4949
with patch("agent.assess_context_or_answer_simple") as mock_preflight, \
50-
patch("agent.openai_chat") as mock_chat:
50+
patch("agent.llm_chat") as mock_chat:
5151
mock_preflight.return_value = (True, "")
5252
mock_chat.side_effect = [{
5353
"content": "hello",
@@ -75,7 +75,7 @@ def test_run_agent_with_session_marks_clarification_responses():
7575

7676
session = Session()
7777

78-
with patch("agent.openai_chat") as mock_chat:
78+
with patch("agent.llm_chat") as mock_chat:
7979
mock_chat.side_effect = [{"content": "Could you share your background and goal?", "tool_calls": None}]
8080
block = run_agent_with_session(
8181
session=session,
@@ -97,7 +97,7 @@ def test_run_agent_with_session_records_usage_in_session_and_block():
9797

9898
with patch("agent.assess_context_or_answer_simple") as mock_preflight, \
9999
patch("agent.run_orchestrator") as mock_orch, \
100-
patch("agent.openai_chat") as mock_chat:
100+
patch("agent.llm_chat") as mock_chat:
101101
mock_preflight.return_value = (True, "")
102102
mock_orch.return_value = [{"title": "Main", "instructions": "test"}]
103103
mock_chat.side_effect = [
@@ -163,7 +163,7 @@ def fake_stream_call(*args, **kwargs):
163163
from models import Block
164164
session.blocks = [Block(id="parent")]
165165

166-
with patch("agent.assess_context_or_answer_simple") as mock_preflight, patch("agent.openai_chat_stream") as mock_stream:
166+
with patch("agent.assess_context_or_answer_simple") as mock_preflight, patch("agent.llm_chat_stream") as mock_stream:
167167
mock_preflight.return_value = (True, "")
168168
mock_stream.side_effect = fake_stream_call
169169
block = run_agent_with_session(
@@ -193,15 +193,13 @@ def test_run_agent_with_session_uses_create_main_block_tool_output():
193193

194194
with patch("agent.assess_context_or_answer_simple") as mock_preflight, \
195195
patch("agent.run_orchestrator") as mock_orch, \
196-
patch("agent.openai_chat") as mock_chat:
196+
patch("agent.llm_chat") as mock_chat:
197197
mock_preflight.return_value = (True, "")
198198
mock_orch.return_value = [{"title": "Main", "instructions": "Use create_main_block"}]
199-
with patch("agent.run_orchestrator") as mock_orch:
200-
mock_orch.return_value = [{"title": "Main", "instructions": "Use create_main_block"}]
201-
mock_chat.side_effect = [
202-
{
203-
"content": "",
204-
"tool_calls": [
199+
mock_chat.side_effect = [
200+
{
201+
"content": "",
202+
"tool_calls": [
205203
{
206204
"id": "call-1",
207205
"type": "function",
@@ -236,7 +234,7 @@ def test_run_agent_with_session_blocks_main_block_until_goal_context_captured():
236234

237235
session = Session(system_prompt="You are a tutor.", user_profile={"knowledge_level": "Beginner", "__context_slots__": "familiarity"})
238236

239-
with patch("agent.openai_chat") as mock_chat:
237+
with patch("agent.llm_chat") as mock_chat:
240238
mock_chat.side_effect = [
241239
{"content": "What are you learning this for (exam, project, or curiosity)?", "tool_calls": None},
242240
]
@@ -259,8 +257,10 @@ def test_run_agent_with_session_keeps_persisted_user_message_text_shape():
259257

260258
session = Session()
261259

262-
with patch("agent.assess_context_or_answer_simple") as mock_preflight, patch("agent.openai_chat") as mock_chat:
260+
with patch("agent.assess_context_or_answer_simple") as mock_preflight, patch("agent.llm_chat") as mock_chat, \
261+
patch("agent.run_orchestrator") as mock_orch:
263262
mock_preflight.return_value = (True, "")
263+
mock_orch.return_value = [{"title": "Main", "instructions": "test"}]
264264
mock_chat.return_value = {"content": "OK", "tool_calls": None}
265265
run_agent_with_session(
266266
session=session,
@@ -393,8 +393,11 @@ def test_run_agent_with_session_sanitizes_file_access_failure_when_search_enable
393393

394394
session = Session(openai_vector_store_id="vs_existing")
395395

396-
with patch("agent.assess_context_or_answer_simple") as mock_preflight, patch("agent.openai_chat") as mock_chat:
396+
with patch("agent.assess_context_or_answer_simple") as mock_preflight, \
397+
patch("agent.run_orchestrator") as mock_orch, \
398+
patch("agent.llm_chat") as mock_chat:
397399
mock_preflight.return_value = (True, "")
400+
mock_orch.return_value = [{"title": "Main", "instructions": "test"}]
398401
mock_chat.return_value = {
399402
"content": (
400403
"Please paste the paper title and abstract. "
@@ -423,14 +426,15 @@ def test_run_agent_with_session_sanitizes_file_access_failure_from_create_main_b
423426

424427
session = Session(openai_vector_store_id="vs_existing")
425428

426-
with patch("agent.assess_context_or_answer_simple") as mock_preflight, patch("agent.openai_chat") as mock_chat:
429+
with patch("agent.assess_context_or_answer_simple") as mock_preflight, \
430+
patch("agent.run_orchestrator") as mock_orch, \
431+
patch("agent.llm_chat") as mock_chat:
427432
mock_preflight.return_value = (True, "")
428-
with patch("agent.run_orchestrator") as mock_orch:
429-
mock_orch.return_value = [{"title": "Main", "instructions": "Use create_main_block"}]
430-
mock_chat.side_effect = [
431-
{
432-
"content": "",
433-
"tool_calls": [
433+
mock_orch.return_value = [{"title": "Main", "instructions": "Use create_main_block"}]
434+
mock_chat.side_effect = [
435+
{
436+
"content": "",
437+
"tool_calls": [
434438
{
435439
"id": "call_1",
436440
"function": {
@@ -447,10 +451,10 @@ def test_run_agent_with_session_sanitizes_file_access_failure_from_create_main_b
447451
},
448452
}
449453
],
450-
},
451-
{"content": "done", "tool_calls": None},
452-
]
453-
block = run_agent_with_session(
454+
},
455+
{"content": "done", "tool_calls": None},
456+
]
457+
block = run_agent_with_session(
454458
session=session,
455459
user_message="summary",
456460
model="gpt-5.2",
@@ -853,7 +857,7 @@ def test_process_async_job_component_edit_selection_patches_only_selected_text()
853857
with patch("lambda_handler.get_jobs_table") as mock_get_table, patch(
854858
"lambda_handler.session_store"
855859
) as mock_store, patch("lambda_handler.run_agent_with_session") as mock_run, patch(
856-
"lambda_handler.openai_chat"
860+
"lambda_handler.llm_chat"
857861
) as mock_openai_chat:
858862
mock_table = MagicMock()
859863
mock_table.get_item.return_value = {
@@ -952,7 +956,7 @@ def test_create_main_block_with_structured_fields_stores_content_nodes():
952956

953957
with patch("agent.assess_context_or_answer_simple") as mock_preflight, \
954958
patch("agent.run_orchestrator") as mock_orch, \
955-
patch("agent.openai_chat") as mock_chat:
959+
patch("agent.llm_chat") as mock_chat:
956960
mock_preflight.return_value = (True, "")
957961
mock_orch.return_value = [{"title": "Main", "instructions": "Use create_main_block"}]
958962
mock_chat.side_effect = [

0 commit comments

Comments
 (0)