test: 補 search/embed/serve 核心測試 + 修 silent failure#9
Merged
Conversation
零測試的三個核心檔補上 12 個單元測試(全程 mock,不載真 BGEM3 模型): - search.py: load_embeddings(temp SQLite) / hybrid_search(fake model 驗 dense+sparse 加權/top_k/score 過濾/排序) / rerank(monkeypatch reranker) - embed.py: get_embedding_text 純函式 / embed_remote dim 驗證 / embed_local - serve.py: handler 契約測試(missing q→400 / bad k→400 / health / stats / happy path / 404),用 __new__ + BytesIO 攔輸出,不起真 server silent failure → logging: - enrich.extract_text_from_html: except: pass → logging.warning - score._call_llm: print(stderr) → logging.warning(移除無用 import sys) 驗證: pytest 64 passed(含舊 52)/ ruff clean。test_enrich 既有測試順手 改 monkeypatch DNS 移除真網路依賴。 Constraint: 15★ public repo,純加法零破壞公開介面 Rejected: package 重構(移 root scripts 進 package)| 會破壞既有 python3 serve.py 用法 + clone 者 import,屬獨立決策不夾帶 Directive: 測試一律 mock 模型,CI 不需 torch GPU Not-tested: 真實 BGEM3 端到端(刻意 mock) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
零測試的三個核心檔(search.py / embed.py / serve.py)補上 12 個單元測試,全程 mock 不載真 BGEM3 模型;並把 enrich/score 兩處 silent failure 改成 logging。
純加法、零破壞公開介面。pytest 64 passed(含舊 52)+ ruff clean。
package 重構刻意不夾帶,屬獨立決策。
🤖 Generated with Claude Code