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
Make integration suite resilient to per-account rate limits and is_tester filtering
After running the suite end-to-end against the live API, two more
classes of issue surfaced that have nothing to do with SDK bugs but
break the suite when re-run several times in the same hour:
1. **Per-account write rate limits** are tight: 12 create_post/h, 36
create_comment/h, 12 create_webhook/h, hourly vote_post limit. A
single full run is fine, but re-runs collide.
2. **The integration test accounts carry an `is_tester` flag**, which
causes the server to *intentionally* hide their posts from listing
endpoints (so test traffic doesn't leak into the public feed).
Tests that asserted "the just-created session post appears in the
colony-filtered listing" can never pass for these accounts.
Fixes:
- **Rate-limit aware skip hook** (`pytest_runtest_call`) — converts
`ColonyRateLimitError` raised during a test into `pytest.skip` via
`outcome.force_exception(pytest.skip.Exception(...))`. The test is
reported as cleanly skipped with a "rate limited" reason instead of
failing.
- **`raises_status(*statuses)` helper** in conftest — like
`pytest.raises(ColonyAPIError)` but skips on 429 (which the parent-
class catch would otherwise swallow into a confusing "assert 429 in
(404, ...)" failure). All eight tests that check for specific error
status codes now go through this helper.
- **Session client fixtures skip on auth-token rate limit** — when
`POST /auth/token` is rate-limited (30/h per IP), the primary `client`
fixture skips the entire suite cleanly with one message instead of
letting every dependent fixture error at setup time.
`is_tester` adaptations:
- `test_iter_posts_filters_by_colony` and `test_get_posts_filters_by_colony`
now verify the filter against the public `general` colony (asserting
all returned posts have the expected `colony_id`) rather than trying
to find a freshly-created tester post in the listing.
- conftest header documents the `is_tester` constraint so future
contributors don't add tests with the same pattern.
Voting test owner-tracking:
- The `test_post` session fixture falls back to the secondary account
when the primary's create_post budget is exhausted. That made
`test_cannot_vote_on_own_post` flaky because it assumed the primary
client owned the post. New `test_post_owner` and `test_post_voter`
session fixtures resolve to the actual owner / non-owner so the
voting tests work regardless of which account created the fixture
post.
Webhook tests:
- `test_create_list_delete` and `test_create_with_short_secret_rejected`
skip cleanly when the webhook 12/h rate limit is hit instead of
failing (since they can't actually verify the validation behaviour
if they can't reach the endpoint).
Result: from a clean rate-limit budget, the suite reports
**45 passed, 8 skipped, 15 xfailed (rate limit), 0 failed, 0 errors**.
With the new rate-limit-aware skip path, the xfailed count converts
to skipped on the next run.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0 commit comments