test: integration suite cleanup — graceful skip, explicit creds, dedupe, dynamic counts#404
Conversation
|
@claude review. Focus on critical issues: bugs, security vulnerabilities, logical errors, data loss risks, performance problems. Do NOT nitpick style, naming conventions, minor formatting, or subjective preferences — only flag issues that could break functionality or cause real harm in production. |
|
Claude finished @axisrow's task in 2m 43s —— View job Claude PR ReviewFocused on critical issues (bugs, security, logical errors, data loss, performance) per request. Verified the credential plumbing against Verdict: No critical issues found. Ship it.The five fixes are real and well-targeted. No bugs, security holes, logical errors, data-loss risks, or performance regressions surfaced. Things I checkedHigh #2 —
High #1 —
Medium #5/#6 — dynamic count derivation (
Medium #3 — dedup in
Checklist
|
…pe, dynamic counts Five fixes from the test-suite audit (issue #396): 1. setUpClass robustness — every TestReadOnly* class whose setUpClass calls a live-API probe (campaign, business, leads-turbo-page, advideo probes) now wraps the call in _skip_class_on_probe_failure so a temporary API outage raises unittest.SkipTest instead of crashing the class with an opaque traceback. 2. Explicit credentials — invoke_get now prepends --token/--login (resolved via conftest._resolve_test_credentials) to every CLI call. Per direct_cli/auth.py:get_credentials, the active direct-auth profile has priority over the YANDEX_DIRECT_TOKEN env var; without explicit flags the integration suite would silently fall through to a developer's production profile when env vars were unset. Matches CLAUDE.md's inverted credential-resolution contract for tests. 3. test_comprehensive.py dedup — the TestCLIHelp class (full duplicate of test_cli.py) is gone. Unique classes (Utils, OutputFormatters, Auth credential chain, ErrorHandling, TestCommandsRegistered) are kept; they cover code paths not exercised elsewhere. 4. test_smoke_matrix.py — replaced hard-coded ``== 144`` and ``== 112`` with self-consistency checks: every expected count is derived from the live Click registry and parsed WSDLs. 5. test_sandbox_write_audit.py — replaced hard-coded ``== 83`` with ``len(commands_for_category(WRITE_SANDBOX))``. All non-live tests pass (1788 passed, 21 skipped). Lint clean. Closes #396. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
cd2c8ad to
6fc93b7
Compare
|
Claude finished @axisrow's task in 1m 28s —— View job Claude PR Re-review (post-rebase)
Verdict: No critical issues found. Rebase looks clean — ship it.What changed since the prior reviewOnly CHANGELOG resolution checkThe Tests block is appended under the existing
Single-version block, single Critical-path checks re-validatedAll four findings from my prior review still hold against the rebased SHA:
Nothing in the rebase resurrected an issue; the audit-fix story is intact. |
Summary
Closes #396 — five fixes from the test-suite audit (2 High, 3 Medium):
High #1: setUpClass crashes on temporary API outage
The seven
TestReadOnly*classes that probe the live API insetUpClass(TestReadOnlyAdGroups,TestReadOnlyAds,TestReadOnlyKeywords,TestReadOnlyDynamicFeedAdTargets,TestReadOnlyLeads,TestReadOnlyBusinesses,TestReadOnlyAdVideos)previously had no try/except — a transient API error gave an opaque
traceback instead of a clean skip. New helper
_skip_class_on_probe_failurecatches any probe exception and raisesunittest.SkipTest(whichsetUpClasshonours by skipping the wholeclass).
High #2: invoke_get silently used the active direct-auth profile
direct_cli/auth.py:get_credentialsgives the activedirect authprofile priority over
YANDEX_DIRECT_TOKENenv var. The integrationsuite previously passed no credentials to
CliRunner.invoke, so onany developer machine with an active profile the tests silently hit
production with profile creds.
invoke_getnow prepends--token/--login(resolved viaconftest._resolve_test_credentials)to every CLI call —
--tokenis priority 1 in the credential chainand beats the profile, matching CLAUDE.md's inverted contract.
Medium #3: test_comprehensive.py partially duplicated test_cli.py
TestCLIHelp(andtest_campaigns_help) were full duplicates ofclasses in
test_cli.py— removed. The remaining classes(
TestCommandsRegistered,TestUtils,TestOutputFormatters,TestAuth,TestErrorHandling) cover surfaces NOT touched bytest_cli.py— kept.Medium #5: hard-coded
== 144and== 112in test_smoke_matrix.pyAdding any CLI command or WSDL operation broke the test with an
opaque message. Replaced with self-consistency checks that derive the
expected counts from the live Click registry and parsed WSDLs.
Medium #6: hard-coded
== 83in test_sandbox_write_audit.pySame pattern: replaced with
len(commands_for_category(WRITE_SANDBOX)).Test plan
pytest --ignore=tests/test_integration.py --ignore=tests/test_v5_live_write.py --ignore=tests/test_v4_live_contracts.py— 1788 passed, 21 skipped, 0 failed.pytest tests/test_integration.py -m integration— 32 passed against live API (read-only).pytest tests/test_comprehensive.py tests/test_smoke_matrix.py tests/test_sandbox_write_audit.py— 44 passed.flake8 tests/test_integration.py tests/test_comprehensive.py tests/test_smoke_matrix.py tests/test_sandbox_write_audit.py— clean.🤖 Generated with Claude Code