Repository navigation
test(sources): Gemini chunkedPrompt message extraction and metadata roundtrip contract (#1297) - #1405
Conversation
29 contract tests over chunks decomposition, content_blocks emission, provider_meta roundtrip, conversation envelope metadata, and per-chunk timestamps. Three synthetic fixtures under tests/data/gemini_chunked_prompt/. Ref #1297
Remove the closure-matrix known_gap now satisfied by test_gemini_chunked_prompt_contract.py; add casts/type-narrowing for mypy strict on the new test file. Ref #1297
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR adds a contract test suite for Gemini's ChangesGemini chunkedPrompt contract test suite
Test closure matrix registration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~35 minutes Possibly related PRs
Suggested labels
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Adds dedicated contract tests for the Gemini AI Studio
chunkedPromptparser(
polylogue/sources/parsers/drive.py+drive_support*) covering chunksdecomposition, content_blocks emission, per-message
provider_metaroundtrip,and conversation envelope metadata. Drops the corresponding
known_gapsbullet from
docs/plans/test-closure-matrix.yamlforsources.parsers.gemini.Problem
docs/plans/test-closure-matrix.yamldeclared:tests/unit/sources/test_parsers_drive.pyexercised dispatch and a few helpercontracts, but the actual decomposition of
chunkedPrompt.chunksintonormalized messages — including the
executableCode/codeExecutionResult/isThought/safetyRatingspaths — had nodedicated assertions. Metadata could regress silently.
Solution
tests/unit/sources/test_gemini_chunked_prompt_contract.pywith 29contract assertions across six classes:
TestChunkedPromptEnvelopeShape— chunks-to-messages decomposition,role guard, top-level
chunksfallback, string-chunk handling.TestPerChunkContentBlocks—thinking/code/tool_resultblock emission from
isThought,executableCode,codeExecutionResult.TestMetadataRoundtrip—provider_meta.rawpreservation,top-level typed projections (
tokenCount,finishReason,thinkingBudget,isThought,safetyRatings,executableCode,codeExecutionResult), plus a full parse → serialize → reparse loopthat proves
rawis sufficient to reconstruct identical messages.TestConversationLevelMetadata— title source precedence (title→displayName→ fallback id),provider_conversation_idderivation,envelope vs chunk-derived
createTime/updateTime.TestPerChunkTimestamps— per-chunkcreateTimepropagation andenvelope fallback.
tests/data/gemini_chunked_prompt/:text_only_prompt.json,code_execution_prompt.json,multi_turn_prompt.json.docs/plans/test-closure-matrix.yaml: drops theknown_gapsbullet forsources.parsers.geminiand lists the new test underrepresentative_tests.Mirrors the structural pattern established for the Codex event-stream
contract in #1296 / PR #1404.
Verification
Closes #1297
Summary by CodeRabbit
Tests
Documentation