Skip to content

Unit tests for with_retry in apple.py and play.py #19

Closed

Description

@FidelisMM

Why

Both store clients retry network calls with exponential backoff, so a dropped connection doesn't leave a screenshot set half-uploaded. The two versions behave differently, and neither is tested.

  • apple.with_retry retries any httpx.TransportError or httpx.HTTPStatusError, then raises AppleError after the last attempt.
  • play.with_retry retries httpx.TransportError, and retries PlayError only when the message contains " HTTP 5". Any other PlayError is raised on the first attempt.

What to do

Create tests/test_retry.py. Patch time.sleep so the tests run instantly, and use a small fake function that fails N times before succeeding.

  • Succeeds after a few transient failures, and returns the value.
  • Gives up after tentativas attempts (Apple wraps the error in AppleError, Play re-raises it).
  • Play: a 4xx PlayError is not retried, a 5xx one is.
  • The backoff waits 2, 4, 8... seconds (check the time.sleep calls).

Done when

  • Tests for both modules
  • CI is green

Getting started

No store credentials or test app needed.

uv sync
uv run python -m unittest discover -s tests -v

Comment here if you'd like to take it, so nobody duplicates the work. Questions are welcome in this thread, and PRs usually get a review within a day.

Activity

  1. CodeByPeace commented on Oct 2, 2026

    @CodeByPeace
    Contributor

    Hello
    I'd like to take this one.
    I'll add tests/test_retry.py covering both apple.with_retry and play.with_retry, with time.sleep patched.

  2. CodeByPeace commented on Oct 2, 2026

    @CodeByPeace
    Contributor

    PR is up: #21. Happy to adjust anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions