Skip to content

test: add unit tests for the synth CLI command (fixes #102)#174

Merged
himanshu231204 merged 1 commit into
OpenAgentHQ:mainfrom
Nitjsefnie:test-102-synth-cli
Jul 17, 2026
Merged

test: add unit tests for the synth CLI command (fixes #102)#174
himanshu231204 merged 1 commit into
OpenAgentHQ:mainfrom
Nitjsefnie:test-102-synth-cli

Conversation

@Nitjsefnie

Copy link
Copy Markdown
Contributor

Fixes #102.

Premise check against current code (this issue batch is dated 2026-07-14)

  • openagent_eval/cli/commands/synth.py exists and is registered as app.command(name="synth") — the issue's premise holds.
  • One flag name in the issue is stale: the real flag is --count/-n, not --num-questions. Tests follow the code.
  • tests/unit/test_cli/test_synth.py already existed with a single _create_provider helper test (not CLI-level). This PR extends that file (existing test preserved) rather than colliding with a new one.

What's covered (12 new tests, CliRunner + strip_ansi, matching the existing CLI-test conventions)

  • corpus/text routing to generate / generate_from_text (mocked SyntheticDataGenerator boundary — no LLM or network is ever touched)
  • --count wiring incl. the default of 10; --adversarial + --types parsing; invalid type → exit 2
  • --chunk-size / --chunk-overlap / --max-concurrent constructor wiring
  • --llm-provider / --llm-model provider selection (offline via the mock provider)
  • usage errors (missing / both corpus+text) → exit 2; SynthesisError → exit 1
  • --output writes the dataset file (real file in tmp_path, contents asserted)

Verification

  • Every test was mutation-checked: 12 targeted breaking changes to synth.py (flag rename, Exit(2)Exit(0), count=1, default 10→5, dropped adversarial_types, chunk_size=999, wrong model, _save_outputpass, …) — each killed by exactly the test that claims to pin it. Two of the twelve were independently re-run before opening this PR (default-count and output-write): both fail on the mutant, pass restored.
  • uv run pytest tests/unit -q: baseline on clean main 1 failed, 839 passed, 4 skipped → with this PR 1 failed, 851 passed, 4 skipped. The single failure is identical and pre-existing (test_metrics/test_generation.py::TestBERTScore::test_identical), unrelated to synth.
  • No production code changed (git diff openagent_eval/ is empty). Env note: uv sync --all-extras was used (plain uv sync leaves optional deps unresolved), and its unrelated uv.lock marker churn was reverted out of the commit.

🤖 This PR was written with AI assistance (Claude), directed and verified by a human-supervised workflow.

Cover argument parsing and wiring for `oaeval synth` using typer's
CliRunner, mocking the SyntheticDataGenerator boundary so no LLM or
network call is made:

- corpus/text routing to generate / generate_from_text
- --count (incl. default of 10), --adversarial + --types parsing
- --chunk-size / --chunk-overlap / --max-concurrent constructor wiring
- --llm-provider / --llm-model provider selection
- usage errors (missing/both corpus+text, invalid adversarial type) -> exit 2
- SynthesisError -> exit 1
- --output writes the dataset to disk

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@himanshu231204
himanshu231204 merged commit fa30083 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.

Add unit tests for the synth CLI command

2 participants