Skip to content

test(reports): cover ReportManager.reconstruct() edge cases (#105)#173

Merged
himanshu231204 merged 1 commit into
OpenAgentHQ:mainfrom
Nitjsefnie:test/105-reconstruct-edge-cases
Jul 17, 2026
Merged

test(reports): cover ReportManager.reconstruct() edge cases (#105)#173
himanshu231204 merged 1 commit into
OpenAgentHQ:mainfrom
Nitjsefnie:test/105-reconstruct-edge-cases

Conversation

@Nitjsefnie

Copy link
Copy Markdown
Contributor

Addresses #105 — adds 12 unit tests for ReportManager.reconstruct(), which had zero coverage.

One correction worth surfacing up front: the issue states reconstruct() "silently creates a default Config when the config section is missing." That's not what the current code does — manager.py:178-182 guards with if not config: and raises ValueError ("'config' section is missing from data"). So I've pinned the actual raise-on-missing behavior rather than the silent-default behavior the issue describes. Raising is the sane behavior here (silently defaulting a missing config would mask a user error), so there's nothing to fix — just flagging that the issue's premise is inaccurate when you close it. (Looks like an artifact of an auto-generated issue.)

Coverage:

  • Happy path — a saved report and a hand-built dict both round-trip; only config is required, the rest default to empty.
  • Missing config — raises ValueError, and because the guard is truthiness (if not config), it fires for a missing key, None, and an empty dict {} (all three parametrized).
  • Malformed data — non-mapping config → TypeError; a non-dict entry in resultsAttributeError; an out-of-range config value → pydantic ValidationError.
  • Missing required fields — a config dict lacking dataset/llmValidationError, with the exact error_count() asserted.

Assertions are on the actual exception types/messages read from the code (matching this repo's preference for exact assertions over snapshots). Mutation-verified: weakening the missing-config guard (if not configif config is None) fails the empty-dict case, and truncating the results reconstruction fails the round-trip length assertion.

uv run pytest tests/unit is green aside from the one pre-existing, unrelated BERTScore float-precision failure (reproduces on clean main); ruff clean on the new file. Tests-only, no production changes.

Disclosure: this contribution was made with AI assistance (Claude), verified against the actual code (not the issue's premise) and mutation-tested before submission.

…tHQ#105)

Add unit tests characterizing reconstruct() behavior:
- happy path round-trip via save_report -> load_report -> reconstruct
- missing/None/empty config section raises ValueError (NOT a silent
  default Config as the issue speculated; pins actual behavior)
- malformed data: non-mapping config -> TypeError, non-dict result
  item -> AttributeError, out-of-range config value -> ValidationError
- missing required config fields -> ValidationError with exact counts

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@himanshu231204
himanshu231204 merged commit b737456 into OpenAgentHQ:main Jul 17, 2026
9 checks passed
@github-actions

Copy link
Copy Markdown

🎉 Congratulations @Nitjsefnie!

Your pull request has been successfully merged into main. 🚀

Thank you for contributing to OpenAgentHQ and helping improve the project.

We truly appreciate your contribution and hope to see you back with more amazing PRs!

Happy Open Sourcing! ❤️

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.

2 participants