Skip to content

refactor(tests): split test_dry_run.py into thematic modules (closes #604)#609

Merged
axisrow merged 3 commits into
mainfrom
ao/issue-604-dry-run-tests
Jul 22, 2026
Merged

refactor(tests): split test_dry_run.py into thematic modules (closes #604)#609
axisrow merged 3 commits into
mainfrom
ao/issue-604-dry-run-tests

Conversation

@axisrow

@axisrow axisrow commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

Splits the monolithic tests/test_dry_run.py (24 898 lines, 1 395 tests) into 15 thematic modules by command type, as specified in issue #604.

Changes

New modules (14 files)

  • test_dry_run_shared.py — shared helpers (_dry_run, _read_dry_run, _rejected, _failing_run, _ids_csv, _write_jsonl)
  • test_dry_run_common.py — cross-cutting tests (generic get semantics, reports, micro-rubles validation, API error hints)
  • test_dry_run_campaigns.pycampaigns add/update/get
  • test_dry_run_strategy_smart.py — SMART campaign bidding strategies
  • test_dry_run_strategy_text.py — TEXT campaign bidding strategies
  • test_dry_run_strategy_unified.py — UNIFIED campaign bidding strategies
  • test_dry_run_strategies.pystrategies service
  • test_dry_run_ads.pyads, adimages, advideos, creatives
  • test_dry_run_adgroups.pyadgroups
  • test_dry_run_keywords.pykeywords, negativekeywordsharedsets
  • test_dry_run_bids.pybids, keywordbids, bidmodifiers
  • test_dry_run_targets.pyaudiencetargets, dynamicads, dynamicfeedadtargets, smartadtargets, retargeting
  • test_dry_run_extensions.pysitelinks, vcards, adextensions, feeds
  • test_dry_run_clients.pyclients, agencyclients

Updated files (2 files)

  • tests/test_dry_run.py — now a 132‑line guard module with:
    • Original rationale docstring preserved
    • Module layout documentation
    • test_dry_run_module_is_importable parametrized guard (14 cases)
  • tests/test_api_coverage.py — updated test_dry_run_exclusion_focused_test_references_exist to scan all test_dry_run*.py files

Verification

Test coverage

Metric Before After Δ
Total tests collected 2577 2591 +14
test_dry_run*.py tests 1395 1409 +14
Original test IDs preserved ✓ (exact diff)

The +14 tests are the new test_dry_run_module_is_importable guard cases (one per module). All 1 395 original test IDs are preserved exactly.

Linting

  • black . — 1 reformatted file (test_dry_run_strategies.py), 14 unchanged
  • flake8 tests/test_dry_run*.py — same line-length violations as the original monolith (copied byte-for-byte; no new style issues)

Execution

  • Full offline suite: 2521 passed, 8 skipped, 62 errors (baseline: 2507 passed, 8 skipped, 62 errors)
  • The +14 passed tests are the new guard cases
  • The 62 errors are pre-existing environment issues (vcr/aiohttp compatibility in test_read_cassettes.py)

Benefits

  • Navigation — easy to find tests for specific commands
  • Parallel execution — smaller modules allow pytest to schedule more granularly
  • Maintainability — clearer understanding of what's tested per command type
  • Onboarding — new contributors can understand test coverage faster

Closes #604

axisrow and others added 3 commits July 22, 2026 10:26
…604)

Split the monolithic 24 898-line test_dry_run.py (1 395 tests) into 15
focused modules by command type:

- test_dry_run_shared.py — shared helpers (_dry_run, _read_dry_run, _rejected,
  _failing_run, _ids_csv, _write_jsonl)
- test_dry_run_common.py — cross-cutting: generic get semantics, reports,
  micro-rubles validation, API error hints
- test_dry_run_campaigns.py — campaigns add/update/get
- test_dry_run_strategy_smart.py — SMART campaign bidding strategies
- test_dry_run_strategy_text.py — TEXT campaign bidding strategies
- test_dry_run_strategy_unified.py — UNIFIED campaign bidding strategies
- test_dry_run_strategies.py — strategies service
- test_dry_run_ads.py — ads, adimages, advideos, creatives
- test_dry_run_adgroups.py — adgroups
- test_dry_run_keywords.py — keywords, negativekeywordsharedsets
- test_dry_run_bids.py — bids, keywordbids, bidmodifiers
- test_dry_run_targets.py — audiencetargets, dynamicads,
  dynamicfeedadtargets, smartadtargets, retargeting
- test_dry_run_extensions.py — sitelinks, vcards, adextensions, feeds
- test_dry_run_clients.py — clients, agencyclients

The original test_dry_run.py is now a 132‑line guard module that:
1. Preserves the historical rationale docstring.
2. Documents the new modular layout.
3. Runs a parametrized test that each split module imports and
   declares at least one test (test_dry_run_module_is_importable).

Updated tests/test_api_coverage.py::test_dry_run_exclusion_focused_test_references_exist
to scan all test_dry_run*.py files (not just test_dry_run.py) when validating
DRY_RUN_PAYLOAD_EXCLUSIONS rationale references.

Coverage:
- Before: 2577 tests collected, 1395 in test_dry_run.py
- After:  2591 tests collected (+14 new guard cases)
- All 1 395 original test IDs preserved exactly (verified by diff)

Flake8 status: same line-length violations as the original monolith
(copied byte-for-byte; no new style issues introduced).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Ruff complains about F401 in the three split modules that originally
inherited the unused `from unittest.mock import patch` import from the
monolith. The import is not used in these specific slices (it is used
elsewhere in the original file).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Closes the last open task of issue #604 ("Update CLAUDE.md testing
documentation"): add a bullet under ## Tests describing the modular
split, and reword the strict-WSDL-parity exclusion clause so it points
at the test_dry_run_*.py suite rather than the historical single file.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@axisrow

axisrow commented Jul 22, 2026

Copy link
Copy Markdown
Owner Author

📋 Review summary — all cycles

Reviewed locally (/review + Codex companion), no bots pinged.

Cycle Reviewer Finding Verdict Resolution
1 codex (none — clean) APPROVE n/a
1 claude (/review) (none — clean) APPROVE n/a

Totals: 0 FIX, 0 SKIP, 0 UNVERIFIED. Both reviewers approved with no findings.

Pre-review gap-fix (step 3): closed the last open task of issue #604 — documented the test_dry_run_*.py modular layout in CLAUDE.md (commit ed21c4c), which the original split had not done.

Coverage check: 1 395 original test node-IDs preserved exactly after the split; full offline suite 2521 passed (+14 new guard parametrization), CI green.

@axisrow
axisrow merged commit eb88810 into main Jul 22, 2026
6 checks passed
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.

refactor(tests): split test_dry_run.py (24 898 lines) into thematic modules

1 participant