Skip to content

test(integration): record real bids cassettes for TestWriteBidsRead - #193

Merged
axisrow merged 1 commit into
mainfrom
test/bidsread-live-cassettes
May 20, 2026
Merged

test(integration): record real bids cassettes for TestWriteBidsRead#193
axisrow merged 1 commit into
mainfrom
test/bidsread-live-cassettes

Conversation

@axisrow

@axisrow axisrow commented May 20, 2026

Copy link
Copy Markdown
Owner

Summary

Previously the TestWriteBidsRead cassettes only captured sandbox_keyword fixture setup (campaigns/adgroups/keywords) because Yandex sandbox rejects keywords.add with code 8800. Both bids tests were skipping in replay-mode, providing no actual /v5/bids endpoint coverage (flagged in PR #189 second-pass Opus review).

Approach

  1. Recorded cassettes against live API (sandbox-bypass via temporary one-line patch to conftest._invoke, immediately reverted).
  2. Rewrote request hosts api.direct.yandex.ruapi-sandbox.direct.yandex.ru in the YAMLs so replay works under the default --sandbox test setup.
  3. Fixed test_bids_set_auto to pass --position PREMIUMBLOCK alongside --scope SEARCH (live API error 9600 otherwise).
  4. Removed the now-obsolete @pytest.mark.sandbox_limitation marker.

Verification

  • pytest -q -m integration_write tests/test_integration_write.py::TestWriteBidsRead2 passed (was 2 skipped).
  • Full integration_write suite: 12 passed, 11 skipped (was 10 passed, 13 skipped — net +2).
  • Offline suite: 677 passed, no regressions.
  • Cassettes contain real /json/v5/bids interactions.
  • Token + login + PII scrubbed by existing VCR hooks; manually verified.

Refs: closes the residual finding from PR #189 second-pass Opus review (TestWriteBidsRead coverage gap).

The original cassettes only captured the sandbox_keyword fixture setup
(campaigns/adgroups/keywords) because the Yandex sandbox rejects
keywords.add with code 8800. As a result, both bids tests skipped in
replay-mode and provided no actual /v5/bids coverage.

Workaround:
- Recorded against the live API (sandbox-bypass via temporary patch to
  conftest._invoke), then rewrote request hosts in the cassettes from
  api.direct.yandex.ru to api-sandbox.direct.yandex.ru so they replay
  under the default --sandbox test setup.
- test_bids_set_auto needed --position PREMIUMBLOCK alongside
  --scope SEARCH (live API error 9600: 'You need to enter Position to
  update the bid for search'). Added the flag.

Result: both tests now PASS in replay-mode and exercise real /v5/bids
interactions. Dropped the @pytest.mark.sandbox_limitation marker on the
class since the limitation is now resolved.

Token, login and identifying personal data scrubbed by the existing VCR
hooks in conftest.py; verified manually post-recording.
Copilot AI review requested due to automatic review settings May 20, 2026 04:49
@axisrow
axisrow merged commit af73969 into main May 20, 2026
8 checks passed
@axisrow
axisrow deleted the test/bidsread-live-cassettes branch May 20, 2026 04:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves integration write test coverage for the v5 bids service by updating the TestWriteBidsRead VCR cassettes so replay-mode exercises real /json/v5/bids interactions (instead of skipping after fixture setup failures).

Changes:

  • Updated TestWriteBidsRead documentation and removed the @pytest.mark.sandbox_limitation marker so the tests run in replay-mode.
  • Fixed test_bids_set_auto to include --position PREMIUMBLOCK alongside --scope SEARCH to satisfy the live API contract.
  • Re-recorded/updated VCR cassettes to include successful bids.get and bids.setAuto interactions, with URIs rewritten to the sandbox host for replay.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tests/test_integration_write.py Un-skips bids read/auto tests and updates the set-auto invocation to include --position.
tests/cassettes/test_integration_write/TestWriteBidsRead.test_bids_get.yaml Cassette now contains a real /json/v5/bids get interaction (plus setup/teardown).
tests/cassettes/test_integration_write/TestWriteBidsRead.test_bids_set_auto.yaml Cassette now contains a real /json/v5/bids setAuto interaction (plus setup/teardown).

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