Skip to content

test: fix CI failures from spec-canonical body shape#185

Merged
pavanputhra merged 1 commit into
mainfrom
worktree-fix-ci-test-failures
May 26, 2026
Merged

test: fix CI failures from spec-canonical body shape#185
pavanputhra merged 1 commit into
mainfrom
worktree-fix-ci-test-failures

Conversation

@pavanputhra
Copy link
Copy Markdown
Contributor

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; new add_attachment intentionally coerces them to encoding=json + JSON-stringified body. Rewrote assertions to match, kept raises for genuinely invalid input.
  • conserver/links/groq_whisper/test_groq_whisper.py::test_get_transcriptiontranscript["body"]["text"] blew up because body is now a JSON string; switched to Vcon.decoded_body(transcript)["text"].
  • conserver/tests/test_link_metrics.py::TestCheckAndTagMetrics::* (3 tests) — overriding analysis[0]["body"] to a plain string left encoding="json" (set by add_analysis when the fixture's dict body was canonicalized). Vcon.with_decoded_body() then raised on json.loads("Hello world"), swallowed silently, no metric recorded. Added analysis[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 passed
  • Full suite runs to completion (610 passed; 2 pre-existing test_api flakes unrelated to this change)

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.
@pavanputhra pavanputhra merged commit edf20d2 into main May 26, 2026
@pavanputhra pavanputhra deleted the worktree-fix-ci-test-failures branch May 26, 2026 12:12
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