Skip to content

Refactor external unittest.TestCase suites into the smoke-test style #322

Description

@Mattsface

Parent: #297

Goal

Replace the remaining unittest.TestCase-based external (live) test suites with the lighter, plain-pytest smoke-test style established by #318 (tests/external_tests/mlb/test_mlb_smoke.py and tests/external_tests/async_mlb/test_async_mlb_smoke.py).

Background

Most of tests/external_tests/ still uses an older pattern: a unittest.TestCase per resource with a setUpClass that hits the live MLB API once, followed by a long list of assertTrue(hasattr(...)) checks for every model field. This duplicates coverage that already exists offline (Pydantic validation, tests/parsers/, tests/models/), is more brittle to upstream field changes, and is heavier to maintain than the newer smoke tests, which just confirm connectivity and that the response parses into the right type.

Scope

Files currently using the unittest.TestCase pattern that should move to the smoke-test style:

  • tests/external_tests/attendance/test_attendance.py
  • tests/external_tests/awards/test_awards.py
  • tests/external_tests/division/test_division.py
  • tests/external_tests/drafts/test_draft.py
  • tests/external_tests/game/test_game.py
  • tests/external_tests/gamepace/test_gamepace.py
  • tests/external_tests/homerunderby/test_homerunderby.py
  • tests/external_tests/league/test_league.py
  • tests/external_tests/mlb/test_mlb.py
  • tests/external_tests/mlbdataadapter/test_mlbadapter.py
  • tests/external_tests/person/test_person.py
  • tests/external_tests/schedule/test_schedule.py
  • tests/external_tests/seasons/test_seasons.py
  • tests/external_tests/sport/test_sport.py
  • tests/external_tests/standings/test_standings.py
  • tests/external_tests/stats/test_catching.py
  • tests/external_tests/stats/test_fielding.py
  • tests/external_tests/stats/test_hitting.py
  • tests/external_tests/stats/test_pitching.py
  • tests/external_tests/stats/test_player_game_stats.py
  • tests/external_tests/team/test_roster.py
  • tests/external_tests/team/test_team.py
  • tests/external_tests/venue/test_venue.py

For each file:

  • Replace the unittest.TestCase class with plain pytest functions, one per endpoint call, matching the shape of test_mlb_smoke.py / test_async_mlb_smoke.py: call the endpoint, assert the return type, and assert one or two representative fields.
  • Drop the per-field hasattr assertions; field-level shape is already the offline suite's job.
  • Keep the live IDs/fixtures already in use (e.g. team 133, sport 1, league 103, division 200) so the smoke tests keep exercising the same real resources.
  • test_mlb.py and test_mlbadapter.py are grab-bag files covering multiple concerns; split their smoke-worthy assertions out per endpoint/resource rather than porting the file as one block.

Constraints

  • These suites only run against the live MLB API (.github/workflows/external-tests.yml, weekly + manual dispatch) and must keep not running as part of the default offline pytest tests/ suite.
  • Do not remove live coverage of any endpoint currently exercised; this is a style refactor, not a coverage reduction.
  • Before deleting a hasattr/ValidationError-style assertion, confirm the same field or required-field behavior is already covered by an offline test (tests/parsers/, tests/models/, or similar); file a note here if a gap is found rather than silently dropping coverage.

Acceptance criteria

  • Every file listed above uses the plain-pytest smoke style instead of unittest.TestCase
  • No live-endpoint coverage is lost relative to today
  • tests/external_tests/ still only runs via the external-tests workflow, not the default suite
  • Any coverage gap discovered during the port is called out explicitly, not silently dropped

Refs #297

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