test(cli): add CLI unit tests and enforce cli.py coverage#8
Conversation
- cli.py was excluded from the coverage gate (only the skipped-by-default smoke suite exercised it), so a CLI regression could land without failing CI. - Add tests/test_cli.py covering the documented exit-code contract: query happy path (JSON on stdout), SnowflakeError -> exit 1 + stderr, no subcommand -> exit 2 + help, --version, and the _json_default serializer for Decimal/datetime/date/time/bytes plus its TypeError branch. - Stub the network by monkeypatching SnowflakeClient.from_env to a FakeSnowflake-backed client, so the tests need no real account. - Drop cli.py from [tool.coverage.run] omit and mark the unreachable defensive return in main() with pragma: no cover (argparse only yields None or query).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds a new ChangesCLI Test Coverage
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
cli.pywas excluded from the coverage gate (only the skipped-by-default smoke suite exercised it), so a CLI regression could land without failing CI.tests/test_cli.pycovering the documented exit-code contract: query happy path (JSON on stdout),SnowflakeError-> exit 1 + stderr, no subcommand -> exit 2 + help,--version, and the_json_defaultserializer for Decimal/datetime/date/time/bytes plus itsTypeErrorbranch.SnowflakeClient.from_envto aFakeSnowflake-backed client, so the tests need no real account.cli.pyfrom[tool.coverage.run] omitand mark the unreachable defensivereturninmain()withpragma: no cover(argparse only yieldsNoneorquery).Review
Internal: clean. External (Codex agentic, Kimi-agentic): both clean, no findings. Claude reviewer skipped (same harness).
Changes
tests/test_cli.py(new, +143)pyproject.toml(coverage omit list)snowflake_sql_api/cli.py(1-line pragma)Test plan
coverage run -m pytest && coverage report: 189 passed, 5 skipped;cli.py100%, total 94% (>= 89% gate)pre-commit run --all-filesclean (ruff, black, mypy, yaml/toml, private-key)Summary by CodeRabbit
Release Notes
Tests
Chores