Skip to content

test: generalize integration polling helpers#920

Draft
vdusek wants to merge 1 commit into
masterfrom
test/unify-polling-helpers
Draft

test: generalize integration polling helpers#920
vdusek wants to merge 1 commit into
masterfrom
test/unify-polling-helpers

Conversation

@vdusek
Copy link
Copy Markdown
Contributor

@vdusek vdusek commented May 29, 2026

Generalizes the two integration-test polling helpers so the same pair can be shared across apify-sdk-python, crawlee-python, and apify-client-python.

  • call_with_exp_backoff no longer takes rq_access_mode. It now takes an optional condition (default: truthy) and retries fn until the condition holds, returning the last result. The Apify RQ single/shared distinction moves to the call sites via max_retries (0 = call once / single mode, 5 = retry / shared mode).
  • poll_until_condition gains the same condition default and now accepts both sync and async callables.
  • Both helpers accept a sync or async fn via a small _maybe_await helper, typed with overloads so the return type is preserved.

All ~36 call sites in test_request_queue.py are refactored accordingly. Lint, type-check, and test collection pass; integration tests require a platform token and were not run locally.

Make call_with_exp_backoff and poll_until_condition generic and consistent
so the same two helpers can be shared across apify-sdk-python,
crawlee-python and apify-client-python:

- call_with_exp_backoff no longer takes rq_access_mode. It now takes an
  optional condition (default: truthy) and retries fn until the condition
  holds, returning the last result. The Apify RQ single/shared distinction
  moves to the call sites via max_retries (0 = call once / single mode,
  5 = retry / shared mode).
- poll_until_condition gains the same condition default and now accepts
  both sync and async callables (so it can poll plain values too).
- Both helpers accept sync or async fn via a small _maybe_await helper,
  typed with overloads so the return type is preserved.

All ~36 call sites in test_request_queue.py are refactored accordingly.
@vdusek vdusek added adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. labels May 29, 2026
@vdusek vdusek self-assigned this May 29, 2026
@github-actions github-actions Bot added this to the 141st sprint - Tooling team milestone May 29, 2026
@github-actions github-actions Bot added the tested Temporary label used only programatically for some analytics. label May 29, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.97%. Comparing base (edd23e6) to head (3052131).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #920      +/-   ##
==========================================
- Coverage   87.00%   86.97%   -0.04%     
==========================================
  Files          48       48              
  Lines        2956     2956              
==========================================
- Hits         2572     2571       -1     
- Misses        384      385       +1     
Flag Coverage Δ
e2e 37.58% <ø> (ø)
integration 58.93% <ø> (+0.03%) ⬆️
unit 75.74% <ø> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vdusek vdusek marked this pull request as draft May 29, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants