Skip to content

test: add ~60 tests to improve coverage from 65% - #11

Merged
Teng91 merged 2 commits into
masterfrom
feat/improve-test-coverage
May 26, 2026
Merged

test: add ~60 tests to improve coverage from 65%#11
Teng91 merged 2 commits into
masterfrom
feat/improve-test-coverage

Conversation

@Teng91

@Teng91 Teng91 commented May 26, 2026

Copy link
Copy Markdown
Owner

New test files:

  • test_prompt.py: build_context() and build_messages() all branches
  • test_chain.py: rag_generate success, RuntimeError, prompt assembly
  • test_base_provider.py: _is_retryable() all branches, generate() paths
  • test_bootstrap.py: _create_provider, _create_strategy, build_llm_service
  • test_provider_implementations.py: Claude/Gemini/OpenRouter with mocked SDKs

Extended existing tests:

  • test_service.py: generic Exception, Untitled fallback, topic_id, None scalar
  • test_resilient_service.py: generic exception fallback, mixed failures, ProviderHandler acquire+record flow
  • test_rate_limit.py: rpd=0, empty window, RPM/TPM full wait
  • test_chat.py (routers): user_id/topic_id/article_id passthrough, 503, set_llm_service

New test files:
- test_prompt.py: build_context() and build_messages() all branches
- test_chain.py: rag_generate success, RuntimeError, prompt assembly
- test_base_provider.py: _is_retryable() all branches, generate() paths
- test_bootstrap.py: _create_provider, _create_strategy, build_llm_service
- test_provider_implementations.py: Claude/Gemini/OpenRouter with mocked SDKs

Extended existing tests:
- test_service.py: generic Exception, Untitled fallback, topic_id, None scalar
- test_resilient_service.py: generic exception fallback, mixed failures,
  ProviderHandler acquire+record flow
- test_rate_limit.py: rpd=0, empty window, RPM/TPM full wait
- test_chat.py (routers): user_id/topic_id/article_id passthrough, 503, set_llm_service

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Teng91 Teng91 self-assigned this May 26, 2026
- Gemini tests: use @patch decorator instead of with-block so mock
  persists through asyncio.to_thread (genai.GenerateContentConfig was
  unmocked when the thread ran)
- sliding_window_strategy._tpm_wait: handle empty deque when a single
  request exceeds TPM — return 0 instead of IndexError

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Coverage

Test Coverage
FileStmtsMissCoverMissing
src/chatbot_plugin
   __init__.py00100% 
   config.py130100% 
   db.py80100% 
   routers.py29389%36–37, 42
   service.py460100% 
src/chatbot_plugin/contracts
   __init__.py30100% 
   requests.py100100% 
   responses.py210100% 
src/chatbot_plugin/llm
   __init__.py60100% 
   base_provider.py270100% 
   bootstrap.py420100% 
   claude_provider.py120100% 
   config.py10190%22
   gemini_provider.py320100% 
   openrouter_provider.py180100% 
   resilient_llm_service.py330100% 
src/chatbot_plugin/llm/rate_limit
   __init__.py40100% 
   no_op_strategy.py60100% 
   quota_strategy.py70100% 
   sliding_window_strategy.py54394%37, 61, 63
src/chatbot_plugin/models
   __init__.py220%3, 5
   article.py22220%7, 9–11, 14–15, 18–19, 21–31, 33, 39–40
src/chatbot_plugin/rag
   __init__.py00100% 
   chain.py80100% 
   prompt.py290100% 
TOTAL4423192% 

Tests Skipped Failures Errors Time
123 0 💤 0 ❌ 0 🔥 15.046s ⏱️

@Teng91
Teng91 merged commit 6534777 into master May 26, 2026
1 check passed
@Teng91
Teng91 deleted the feat/improve-test-coverage branch May 26, 2026 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant