Skip to content

Add mock test coverage for LLMTranslator (make_chunks + translate) - #78

Merged
zh-plus merged 1 commit into
zh-plus:masterfrom
iautolab:feature/add-llm-translator-tests
Mar 2, 2026
Merged

Add mock test coverage for LLMTranslator (make_chunks + translate)#78
zh-plus merged 1 commit into
zh-plus:masterfrom
iautolab:feature/add-llm-translator-tests

Conversation

@MaleicAcid

Copy link
Copy Markdown
Collaborator

Add tests/test_llm_translator.py with comprehensive unit and mock tests for LLMTranslator, preparing for the issue #59 pipeline decoupling refactor.

New tests

TestMakeChunks — 7 pure unit tests (no mocks)

  • test_basic — standard multi-chunk split
  • test_exact_fit — texts exactly fill one chunk
  • test_merge_small_tail — small trailing chunk merged into previous
  • test_no_merge_large_tail — large trailing chunk kept separate
  • test_empty — empty input
  • test_single_item — single text
  • test_line_numbers — line numbers start at 1 and increment continuously across chunks

TestLLMTranslatorTranslate — 6 mock tests (no API calls)

  • test_single_chunk — texts fitting in one chunk, translate_chunk called once
  • test_multiple_chunks — texts spanning 2 chunks, translate_chunk called twice
  • test_context_passing_between_chunks — summary from chunk N appears in chunk N+1's context
  • test_length_mismatch_triggers_atomic — wrong-length translation triggers atomic_translate fallback
  • test_retry_agent_used_on_primary_failure — primary agent failure activates retry agent
  • test_resume_from_compare_file — translation resumes from saved intermediate JSON, skipping completed chunks

All tests mock ChunkedTranslatorAgent and ContextReviewerAgent to avoid real API calls.

@MaleicAcid

MaleicAcid commented Feb 25, 2026

Copy link
Copy Markdown
Collaborator Author

There will be at least 2-3 additional PRs coming to refine the translation tests. Solid test coverage is a prerequisite for us to proceed with the refactoring safely and smoothly.
The world is changeing. We need move fast. @zh-plus Feel free to bounce any ideas off me whenever you want.

@zh-plus

zh-plus commented Mar 2, 2026

Copy link
Copy Markdown
Owner

thanks for your pr!

@zh-plus
zh-plus merged commit fd6b765 into zh-plus:master Mar 2, 2026
10 checks passed
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.

2 participants