Skip to content

test(api): use unbound session in app generate tests - #45130

Merged
asukaminato0721 merged 1 commit into
langgenius:mainfrom
lj1166:test/use-unbound-session-in-app-generate-service
Oct 30, 2026
Merged

asukaminato0721 merged 1 commit into
langgenius:mainfrom
lj1166:test/use-unbound-session-in-app-generate-service

Conversation

@lj1166

@lj1166 lj1166 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Part of #44973.

Replaces the three remaining placeholder MagicMock() sessions in test_app_generate_service.py with the shared unbound_session fixture already used by TestGenerate. These paths mock the workflow lookup and should not require database access; the unbound fixture keeps that contract explicit by failing if a test unexpectedly touches a bound database.

Screenshots

Not applicable; this is a backend unit-test-only change.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion or issues.
  • I've verified the change and updated tests where meaningful regression risk justifies coverage.
  • This change requires a documentation update.
  • I ran make lint && make type-check (backend) and vp staged (frontend) to appease the lint gods.

Verification

  • uv run --no-sync --project api pytest api/tests/unit_tests/services/test_app_generate_service.py -> 59 passed
  • uv run --no-sync --project api ruff check api/tests/unit_tests/services/test_app_generate_service.py
  • uv run --no-sync --project api ruff format --check api/tests/unit_tests/services/test_app_generate_service.py

From Codex

Signed-off-by: lj1166 <2832274602@qq.com>
@lj1166
lj1166 requested a review from QuantumGhost as a code owner October 30, 2026 06:19
@github-actions github-actions Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Oct 30, 2026
@asukaminato0721 asukaminato0721 self-assigned this Oct 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-10-30 07:44:50.527378984 +0000
+++ /tmp/pyrefly_pr.txt	2026-10-30 07:44:36.679397154 +0000
@@ -2773,33 +2773,17 @@
 ERROR Argument `list[Unknown]` is not assignable to parameter `llm_response` with type `Generator[LLMResultChunk]` in function `core.agent.output_parser.cot_output_parser.CotAgentOutputParser.handle_react_stream_output` [bad-argument-type]
    --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:195:71
 ERROR Argument `list[Unknown]` is not assignable to parameter `llm_response` with type `Generator[LLMResultChunk]` in function `core.agent.output_parser.cot_output_parser.CotAgentOutputParser.handle_react_stream_output` [bad-argument-type]
-   --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:207:71
-ERROR No matching overload found for function `str.join` called with arguments: (list[AgentScratchpadUnit.Action | str]) [no-matching-overload]
-   --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:208:23
-ERROR Argument `list[Unknown]` is not assignable to parameter `llm_response` with type `Generator[LLMResultChunk]` in function `core.agent.output_parser.cot_output_parser.CotAgentOutputParser.handle_react_stream_output` [bad-argument-type]
-   --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:215:75
-ERROR No matching overload found for function `str.join` called with arguments: (list[AgentScratchpadUnit.Action | str]) [no-matching-overload]
-   --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:216:27
-ERROR Argument `list[Unknown]` is not assignable to parameter `llm_response` with type `Generator[LLMResultChunk]` in function `core.agent.output_parser.cot_output_parser.CotAgentOutputParser.handle_react_stream_output` [bad-argument-type]
-   --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:221:71
-ERROR No matching overload found for function `str.join` called with arguments: (list[AgentScratchpadUnit.Action | str]) [no-matching-overload]
-   --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:222:25
-ERROR Argument `list[Unknown]` is not assignable to parameter `llm_response` with type `Generator[LLMResultChunk]` in function `core.agent.output_parser.cot_output_parser.CotAgentOutputParser.handle_react_stream_output` [bad-argument-type]
-   --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:229:71
-ERROR No matching overload found for function `str.join` called with arguments: (list[AgentScratchpadUnit.Action | str]) [no-matching-overload]
-   --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:230:25
-ERROR Argument `list[Unknown]` is not assignable to parameter `llm_response` with type `Generator[LLMResultChunk]` in function `core.agent.output_parser.cot_output_parser.CotAgentOutputParser.handle_react_stream_output` [bad-argument-type]
-   --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:242:71
+   --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:205:71
 ERROR Argument `list[Unknown]` is not assignable to parameter `llm_response` with type `Generator[LLMResultChunk]` in function `core.agent.output_parser.cot_output_parser.CotAgentOutputParser.handle_react_stream_output` [bad-argument-type]
-   --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:255:71
+   --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:218:71
 ERROR Argument `list[Unknown]` is not assignable to parameter `llm_response` with type `Generator[LLMResultChunk]` in function `core.agent.output_parser.cot_output_parser.CotAgentOutputParser.handle_react_stream_output` [bad-argument-type]
-   --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:263:71
+   --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:226:71
 ERROR No matching overload found for function `str.join` called with arguments: (list[AgentScratchpadUnit.Action | str]) [no-matching-overload]
-   --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:264:38
+   --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:227:38
 ERROR Argument `list[Unknown]` is not assignable to parameter `llm_response` with type `Generator[LLMResultChunk]` in function `core.agent.output_parser.cot_output_parser.CotAgentOutputParser.handle_react_stream_output` [bad-argument-type]
-   --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:284:71
+   --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:247:71
 ERROR No matching overload found for function `str.join` called with arguments: (list[AgentScratchpadUnit.Action | str]) [no-matching-overload]
-   --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:286:25
+   --> tests/unit_tests/core/agent/output_parser/test_cot_output_parser.py:249:25
 ERROR `None` is not assignable to attribute `agent_callback` with type `DifyAgentCallbackHandler` [bad-assignment]
    --> tests/unit_tests/core/agent/test_cot_agent_runner.py:121:29
 ERROR Object of class `DummyRunner` has no attribute `session` [missing-attribute]

@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 81.42% 81.43% +0.01%
Strict coverage 81.12% 81.13% +0.01%
Typed symbols 83,258 83,247 -11
Untyped symbols 19,073 19,058 -15
Modules 4242 4242 0

@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.56%. Comparing base (7cfaaa7) to head (bf62e6e).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #45130      +/-   ##
==========================================
- Coverage   80.57%   80.56%   -0.01%     
==========================================
  Files        6239     6239              
  Lines      396374   396374              
  Branches    79948    79948              
==========================================
- Hits       319365   319354      -11     
- Misses      70712    70724      +12     
+ Partials     6297     6296       -1     
Flag Coverage Δ
api 89.65% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@asukaminato0721
asukaminato0721 added this pull request to the merge queue Oct 30, 2026
Merged via the queue into langgenius:main with commit b543ff5 Oct 30, 2026
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants