Skip to content

Share refusal assertions in project creation tests - #152

Merged
Deicyde merged 2 commits into
mainfrom
golf/project-create-tests
Oct 6, 2026
Merged

Deicyde merged 2 commits into
mainfrom
golf/project-create-tests

Conversation

@Deicyde

@Deicyde Deicyde commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #96. Every refusal test in tests/test_project_create.py repeated the same checks: the expected error code, no target, no .autoform-new-* stage, and an unchanged parent. This change adds _refused(target, code, **options). It asserts the code and that the parent's listing is unchanged, which covers all three of the other checks.

Also in this change:

  • The workflow-pin outcome tests become two parametrized tables, test_workflow_pin_resolution and test_creation_omits_workflows_without_a_usable_checkout_pin, with one row per former case.
  • The non-string package test becomes a row of the invalid-package list.
  • A second commit formats the file and the autoform_cli.project re-export at the file's existing 120-column width (ruff format, line-length = 120, skip-magic-trailing-comma). It changes no tests.

Every former case is still a test item. This touches only tests and the re-export's line breaks. It is independent of the create.py follow-up; the two merge cleanly.

Tests: ruff check is clean. tests/test_project_create.py: 249 passed, the same 249 items main collects.

Add _refused, which expects an error code and asserts the target's parent
listing is unchanged; that covers both the no-target-no-stage and the
empty-parent checks the refusal tests repeated. Fold the workflow pin
outcome tests into one resolution table plus the omitted-workflows
parametrization, and the non-string package into the invalid-package list.
Every former case remains a parametrized row.
Collapse exploded argument lists, signatures and imports in the project
creation tests and the package re-export to the 120-column style the
test file already uses. No test changes.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 6, 2026
@Deicyde Deicyde added the review: ready Review complete with no known merge blockers label Oct 6, 2026
@Deicyde
Deicyde marked this pull request as ready for review October 6, 2026 04:31
@Deicyde

Deicyde commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Exact-head review at 0b6eee20: the shared refusal helper strictly preserves the former error-code, absent-target/stage, and unchanged-parent assertions; workflow and invalid-type cases map one-for-one. All 249 focused tests and every GitHub check pass. No production code or blocker remains.

@Deicyde
Deicyde merged commit e09048d into main Oct 6, 2026
9 checks passed
@Deicyde

Deicyde commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Post-merge notes on 0b6eee2, which merged as e09048d. Line numbers are at main 71b251c.

Verdict: nothing to fix after the merge. _refused keeps every assertion it replaced, as the review above says. One small piece of test golf is left, plus a process note.

  1. Three refusal tests still spell out _refused by hand (golf, 14 lines). The body says every refusal test repeated the same checks; these three have exactly _refused's shape and were left as they were:

    • tests/test_project_create.py:427-431 becomes _refused(tmp_path / "project", "project-release-unknown", release_id="unknown");
    • :843-848 becomes _refused(target, "project-create-validation-failed");
    • :1722-1727 becomes assert "chmod g-w,o-w" in _refused(parent / "Project", "project-parent-unsafe").message, matching :753.

    Each keeps or strengthens its assertions, because an unchanged parent listing implies both the absent target and the empty stage glob. Verify the staged project tree once during creation #151 edits the tests around :843, so this fits best after Verify the staged project tree once during creation #151 lands.

  2. The formatting commit can't be reproduced from the repo's config (process note, no action now).

    • 0b6eee2 (+41/-190) reflowed test signatures that the first commit never touched, and the autoform_cli/project/__init__.py re-export.
    • The body cites skip-magic-trailing-comma, but pyproject.toml:49-50 sets only line-length = 120. CI and the Makefile run ruff check only.
    • CONTRIBUTING.md:58-59 says "CI runs no formatter, so match the surrounding code instead of reformatting unrelated lines."

    Reverting it now would only add churn; the note is for future golf PRs.

Not run locally.

Posted by PR swarm: PR Swarm Lead

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

Labels

CLA Signed This label is managed by the Meta Open Source bot. review: ready Review complete with no known merge blockers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant