Skip to content

Tests: add a sixth golden fixture from a real-world Django project #51

Description

@FROWNINGdev

Context

The golden-fixture suite vendors real models.py files from five established Django projects — Zulip, Saleor, Wagtail, django-CMS and Mezzanine — and asserts the parser both survives them (cli/tests/test_golden_fixtures.py) and produces byte-stable output (cli/tests/test_golden_snapshots.py). This is how parser regressions get caught against code nobody on this project wrote.

Five projects is a decent spread, but it skews toward CMS-shaped schemas. Adding a project from a different domain — e-commerce with heavy Decimal/inventory modelling, or a docs platform, or anything leaning on abstract base classes and multi-table inheritance — buys real coverage.

What to change

scripts/fetch_golden_fixtures.py reproduces the vendored tree from GitHub via gh api, so this is mostly mechanical:

  1. Pick a project and verify its licence permits verbatim redistribution — Apache-2.0, BSD-2-Clause, BSD-3-Clause and MIT are all fine. Copyleft licences such as GPL/AGPL are not, so Weblate, Misago and Taiga are out. django-oscar (BSD-3-Clause) and readthedocs.org (MIT) are both reasonable candidates if you want one picked for you.
  2. Add it to the fetch script and run it. Vendor only models.py files, each at its original relative path — scan_workspace relies on those paths to infer app-directory boundaries.
  3. Preserve every top-of-file copyright and licence header unchanged.
  4. Add the project to the attribution table in cli/tests/fixtures/golden/README.md and update the Fetch date line.
  5. Generate the snapshot:
    cd cli && UPDATE_GOLDEN_SNAPSHOTS=1 python -m pytest tests/test_golden_snapshots.py
    The snapshot must land at fixtures/golden/<project>.snapshot.json — a plain file beside the project directory, never inside it. test_golden_fixtures.py treats every subdirectory of golden/ as a vendored project via iterdir, so a nested snapshot folder breaks its parametrization.

Watch out for

There is a hard performance gate: all golden fixtures combined must scan in under 2 seconds (test_golden_fixtures.py:35). If the project you pick is enormous, vendor a representative subset of apps rather than everything.

Acceptance criteria

  • pytest cli/tests -v green, including the 2-second budget.
  • Snapshot committed; attribution table and fetch date updated.
  • The PR states the project's licence and links its LICENSE file.

Getting started

pip install -e "cli[dev]"
pytest cli/tests/test_golden_fixtures.py cli/tests/test_golden_snapshots.py -v

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions