Skip to content

Add sync/async behavioral parity tests #304

Description

@Mattsface

Parent: #297
Depends on: #303

Goal

Add tests that protect against behavioral drift between synchronous Mlb methods and their asynchronous AsyncMlb equivalents.

Contract source

#298 defines the public async contract. These tests should compare externally visible behavior, not require sync and async internals to be architecturally identical.

Scope

For endpoints implemented in both clients, feed equivalent response fixtures through each path and compare:

  • Returned model types
  • Parsed field values
  • None, [], and {} behavior
  • Endpoint-specific 404 behavior
  • Structured exception types and key attributes
  • Strict HTTP behavior
  • Explicit compatibility-mode behavior
  • Successful empty-body behavior
  • JSON decode error behavior
  • Timeout and transport exception semantics where the endpoint path exposes them

Initial parity coverage must include:

  • get_team
  • get_person
  • get_schedule

Contract requirements from #298

Equivalent sync/async behavior should include:

2xx                         -> equivalent domain result
404                         -> equivalent endpoint-specific empty behavior
non-404 4xx + strict=True   -> MlbHttpError
non-404 4xx + strict=False  -> compatibility warning + equivalent empty behavior
5xx                         -> MlbHttpError
timeout                     -> MlbTimeoutError
transport failure           -> MlbTransportError
invalid successful JSON     -> MlbDecodeError

Also compare where practical:

  • MlbHttpError status code, reason, URL, method, and public response context
  • MlbHttpCompatibilityWarning category and caller-facing behavior
  • Parsing/model output from shared helpers
  • Public constructor defaults and endpoint signatures that are intended to mirror sync

Async-specific semantics such as asyncio.CancelledError, aclose(), and concurrent same-client usage belong primarily to #302/#303 and do not need artificial sync equivalents.

Constraints

  • Compare public behavior, not private implementation details
  • Do not require sync and async transports to use the same HTTP library or retry implementation
  • Keep tests deterministic and offline
  • Existing synchronous behavior is the compatibility baseline; do not change sync solely to make a parity test easier

Acceptance criteria

  • get_team, get_person, and get_schedule have sync/async parity coverage
  • Equivalent fixtures produce equivalent domain model types and values
  • Equivalent empty fixtures produce equivalent None, [], or {} behavior
  • 404 semantics match
  • Strict and compatibility non-404 4xx semantics match
  • 5xx, timeout, transport, and decode public exception semantics match where applicable
  • Structured public HTTP error context is compared where practical
  • Tests clearly identify which side drifted when parity breaks
  • Existing synchronous tests remain green

Refs #297
Contract: #298

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions