You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Several write integration scenarios are blocked by Yandex Direct sandbox behavior tracked in #28. Some of those flows can be tested safely against the live API if the test creates disposable draft objects and deletes them immediately.
Yandex Direct campaigns can be created as drafts. A draft campaign can be created and deleted without serving ads, as long as the test never submits anything to moderation, never resumes an existing object, and never touches user-owned existing IDs.
Goal
Add a separate guarded live-write test tier that validates the safest production API mutation path:
create a disposable draft campaign;
verify it is not serving (Status=DRAFT and/or State=OFF);
delete it;
prove cleanup happened.
This becomes the foundation for testing sandbox-limited write flows that need real API persistence.
Safety contract
The live-write tier must be opt-in only.
Required guardrails:
use a dedicated pytest marker, for example integration_live_write;
skip unless YANDEX_DIRECT_LIVE_WRITE=1 is set;
require YANDEX_DIRECT_TOKEN;
optionally require YANDEX_DIRECT_LOGIN for agency/client isolation;
generated campaign names must use a unique prefix: direct-cli-live-test-<timestamp>-<uuid>;
tests may mutate only IDs created inside the same test run;
cleanup must run in finally;
no test may call moderate;
no test may call resume on production objects;
no test may update/delete/archive/suspend existing user objects;
failed cleanup must print the created IDs and fail loudly.
Initial scope
Implement only the minimal draft lifecycle first:
direct campaigns add --name direct-cli-live-test-<suffix> --start-date <tomorrow>
direct campaigns get --ids <created-id> --fields Id,Name,Status,State
direct campaigns delete --id <created-id>
direct campaigns get --ids <created-id> --fields Id,Name,Status,State
Expected result:
campaigns add returns a campaign ID;
campaigns get confirms the campaign is draft/inactive before deletion;
campaigns delete succeeds;
final campaigns get confirms the object is gone or no longer returned.
Follow-up scope after the root fixture is proven
Use the disposable draft campaign as the safe root for selected sandbox-limited checks:
Candidate
Live-write safety
Notes
adimages add/delete
low
standalone asset, should be tested next
sitelinks add/delete
low-medium
standalone sitelink set, do not attach to active ads
adgroups add/update/delete
medium
only inside disposable draft campaign
ads add/update/delete
medium
only inside disposable draft campaign/adgroup; never call moderate
keywords add/update/delete
medium
only inside disposable draft adgroup
bids set, keywordbids set
medium-high
only on disposable keyword created in the same run
audiencetargets add/delete
medium-high
only with disposable adgroup/list fixtures
dynamicads / smartadtargets
high
manual-only until draft fixture safety is proven
Implementation notes
Add marker registration in pytest config: integration_live_write: opt-in live production write tests.
Add fixtures for:
live-write opt-in guard;
unique test suffix;
live draft campaign create/delete.
Keep existing integration_write sandbox/VCR suite unchanged.
Do not run integration_live_write in normal CI.
If VCR is used later, cassettes must be reviewed for token/login leaks before commit.
Acceptance criteria
Running normal tests does not hit the live API.
Running without YANDEX_DIRECT_LIVE_WRITE=1 skips the live-write test.
Running with explicit opt-in creates exactly one disposable draft campaign and deletes it.
Test output includes the created campaign ID.
No existing campaign/ad/adgroup/keyword IDs can be passed into the test path.
Problem
Several write integration scenarios are blocked by Yandex Direct sandbox behavior tracked in #28. Some of those flows can be tested safely against the live API if the test creates disposable draft objects and deletes them immediately.
Yandex Direct campaigns can be created as drafts. A draft campaign can be created and deleted without serving ads, as long as the test never submits anything to moderation, never resumes an existing object, and never touches user-owned existing IDs.
Goal
Add a separate guarded live-write test tier that validates the safest production API mutation path:
Status=DRAFTand/orState=OFF);This becomes the foundation for testing sandbox-limited write flows that need real API persistence.
Safety contract
The live-write tier must be opt-in only.
Required guardrails:
integration_live_write;YANDEX_DIRECT_LIVE_WRITE=1is set;YANDEX_DIRECT_TOKEN;YANDEX_DIRECT_LOGINfor agency/client isolation;direct-cli-live-test-<timestamp>-<uuid>;finally;moderate;resumeon production objects;Initial scope
Implement only the minimal draft lifecycle first:
Expected result:
campaigns addreturns a campaign ID;campaigns getconfirms the campaign is draft/inactive before deletion;campaigns deletesucceeds;campaigns getconfirms the object is gone or no longer returned.Follow-up scope after the root fixture is proven
Use the disposable draft campaign as the safe root for selected sandbox-limited checks:
adimages add/deletesitelinks add/deleteadgroups add/update/deleteads add/update/deletemoderatekeywords add/update/deletebids set,keywordbids setaudiencetargets add/deletedynamicads/smartadtargetsImplementation notes
integration_live_write: opt-in live production write tests.integration_writesandbox/VCR suite unchanged.integration_live_writein normal CI.Acceptance criteria
YANDEX_DIRECT_LIVE_WRITE=1skips the live-write test.Related