test: cover ContentTranslator and PlanParser (Batch C)#2877
Merged
Conversation
Batch C — test reinforcement for two modules the health assessment flagged as having no tests: - tests/test_translator.py (16): language detection (ko/en/mixed/empty), the already-in-target-language short-circuits (asserts the LLM is NOT called), model-wrapper stripping, KO→EN/EN→KO failure handling, and ensure_bilingual orchestration. The LLM is replaced by a FakeRouter so the logic is exercised deterministically without network/Ollama. - tests/test_plan_parser.py (12): PlanParser.parse() end-to-end on a sample plan (title, tech-stack detection across frontend/backend/db/blockchain, features, risks, KPIs, summary), edge cases (empty content, Plan: prefix title), and _detect_tech_stack on alternate stacks. ruff + black clean, 225 tests pass (28 new). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adversarial review of the new tests surfaced an inconsistency: translate_to_ english strips its 'english translation:' prefix case-insensitively, but translate_to_korean matched 'Korean translation:' case-sensitively, so a lowercase model reply leaked the wrapper. Make both consistent; add a test. Co-Authored-By: Claude Opus 4.8 <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.
Summary — Test reinforcement (Batch C)
Adds unit coverage for two modules the codebase health assessment flagged as zero-coverage, without requiring an LLM/network (the translator's router is replaced by a
FakeRouter;PlanParser.parse()is synchronous regex parsing).tests/test_translator.py(16 tests)_detect_language: Korean / English / empty / numbers-only / mostly-English-with-some-Korean / mostly-Korean.translate_to_english/translate_to_koreanreturn the input unchanged when it's already in the target language and assert the LLM is never called; empty input →"".English/Korean translation:prefixes and---separators; KO→EN failure path returns"".ensure_bilingual: Korean input keeps Korean + fills English (and vice-versa); empty →("", "").tests/test_plan_parser.py(12 tests)parse()end-to-end on a representative plan: H1 title, explicit-title override, tech-stack detection (next.js / fastapi / postgresql / ethereum, with react inadditional), feature/risk/KPI extraction, summary, raw-content preservation.Untitled Project,Plan:-prefix title fallback._detect_tech_stackon an alternate stack (vue/django/solana) and a no-tech string.Verification
🤖 Generated with Claude Code