Skip to content

test: add unit tests for granite formatters (3.2, 3.3, intrinsics) #812

Closed

Description

@planetf1

Problem

mellea/formatters/granite/ has 7–13% line coverage. The only existing tests (test_intrinsics_formatters.py) are gated behind e2e + huggingface + require_gpu(min_vram_gb=12), so they never run in CI or on most developer machines. Regressions in parsing, serialisation, and OpenAI SDK compatibility go undetected until someone runs the full GPU suite.

Proposal

Add 199 pure unit tests (no GPU, no network, no model downloads, ~35s total) covering:

File Tests What it covers
test_granite3_shared.py 20 find_substring_in_text, create_dict, parse_hallucinations_text, hallucination/citation span helpers
test_granite32_output.py 25 3.2 output processor: citation parsing (<co>N</co>), model output splitting, validation, transform() pipeline
test_granite33_output.py 22 3.3 output processor: JSON-delimited citations/hallucinations, <think>/<response> extraction, controls cleanup
test_granite32_input.py 33 3.2 input processor: system message matrix (tools/docs/thinking/controls), sanitize, transform()
test_granite33_input.py 29 3.3 input processor: same matrix, available_tools role, per-document document_id role
test_intrinsics_canned_output.py 52 Regression: canned model outputs through IntrinsicsResultProcessor, Pydantic schema validation of all test fixtures
test_openai_compat.py 18 All input JSON fixtures pass OpenAI SDK request validation; rewritten inputs likewise

All tests auto-receive the unit marker and run in the default pytest invocation.

Notes

  • Branch: test/granite-formatter-unit-tests (ready for review)
  • Part of Epic: Testing Infrastructure & Strategy Overhaul #726
  • Granite 4 models reuse Granite 3 formatters — no separate tests needed
  • Canned output regression tests currently cover scenarios with local YAML configs (answerability, query_rewrite, query_clarification); additional scenarios need HuggingFace Hub YAML and are covered by the existing e2e suite

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions