test: fix CI failures from spec-canonical body shape#185
Merged
Conversation
PR #182 made add_analysis/add_attachment coerce dict/list bodies to JSON-encoded strings (forcing encoding=json). Three test files still asserted the old in-memory dict shape and broke CI on main: - test_encoding: rewrote the two pytest.raises blocks that expected dict/list bodies to raise; new code intentionally coerces. Replaced with assertions on the new shape, plus new raises for genuinely invalid input (bad JSON string, bad base64 string). - test_get_transcription: switched to Vcon.decoded_body(transcript) before drilling into body["text"], since body is now a JSON string. - TestCheckAndTagMetrics (3 tests): overriding analysis[0]["body"] with a plain string while leaving encoding=json caused with_decoded_body to crash on json.loads("Hello world"); the link's outer try/except swallowed the error and no metric was recorded. Also override encoding to "none" alongside the body override.
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
Fixes the 5 unit-test failures introduced by PR #182 (
fix(vcon): decode body per spec on read, canonicalize on write):common/tests/test_encoding.py::test_encoding— old test asserted dict/list bodies raise; newadd_attachmentintentionally coerces them toencoding=json+ JSON-stringified body. Rewrote assertions to match, kept raises for genuinely invalid input.conserver/links/groq_whisper/test_groq_whisper.py::test_get_transcription—transcript["body"]["text"]blew up because body is now a JSON string; switched toVcon.decoded_body(transcript)["text"].conserver/tests/test_link_metrics.py::TestCheckAndTagMetrics::*(3 tests) — overridinganalysis[0]["body"]to a plain string leftencoding="json"(set byadd_analysiswhen the fixture's dict body was canonicalized).Vcon.with_decoded_body()then raised onjson.loads("Hello world"), swallowed silently, no metric recorded. Addedanalysis[0]["encoding"] = "none"alongside each body override.Test-only change; no production code touched.
Test plan
pytest common/tests/test_encoding.py conserver/links/groq_whisper/test_groq_whisper.py::test_get_transcription conserver/tests/test_link_metrics.py::TestCheckAndTagMetrics→ 5 passedtest_apiflakes unrelated to this change)