tests.test_pr moduleΒΆ

Tests for repomatic.github.pr.

tests.test_pr.BRANCH = 'sync-fruit-basket'ΒΆ

Arbitrary head branch the sync tests target.

tests.test_pr.BASE_SHA = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'ΒΆ

Stand-in SHA for the base branch tip.

tests.test_pr.CANDIDATE_SHA = 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'ΒΆ

Stand-in SHA for the commit built from the working tree.

tests.test_pr.REMOTE_SHA = 'cccccccccccccccccccccccccccccccccccccccc'ΒΆ

Stand-in SHA for the tip of an already-published head branch.

tests.test_pr.OTHER_SHA = 'dddddddddddddddddddddddddddddddddddddddd'ΒΆ

Stand-in SHA for a tip a concurrent run published after this one read it.

tests.test_pr.test_list_open_prs_by_branch_filters_arguments()[source]ΒΆ
tests.test_pr.test_list_open_prs_by_branch_empty()[source]ΒΆ
tests.test_pr.test_list_changed_files_reads_every_page()[source]ΒΆ

The files of every page come back as paths, in API order.

tests.test_pr.test_close_pr_deletes_branch()[source]ΒΆ
tests.test_pr.test_close_pr_unlocks_a_locked_conversation()[source]ΒΆ

A hand-locked PR is unlocked so the retire path’s close comment lands.

tests.test_pr.test_close_open_prs_on_branch_no_match_is_noop()[source]ΒΆ
tests.test_pr.test_close_open_prs_on_branch_closes_every_match()[source]ΒΆ
tests.test_pr.test_close_stale_bump_prs_retires_the_bump_branch(part)[source]ΒΆ

The pull request of a bump no longer allowed closes, saying why.

tests.test_pr.test_needs_push(candidate_tree, remote_tree, remote_commits, expected_commits, expected)[source]ΒΆ
tests.test_pr.git(monkeypatch)[source]ΒΆ

A stand-in for the git layer, wired to the ordinary happy path.

Each test overrides only the calls its own scenario turns on, which keeps the interesting difference visible instead of buried in a stack of patches.

tests.test_pr.gh(monkeypatch)[source]ΒΆ

Capture gh invocations, returning whatever the test queues up.

One stub covers every dispatch point: the module’s own calls, the listings parsed through the gh module, and the close path and label writes of the threads module. A single mock keeps each test’s call sequence in one list.

tests.test_pr.verbs(gh_stub)[source]ΒΆ

The gh <noun> <verb> pairs a test’s run produced, in order.

Return type:

list[str]

tests.test_pr.test_upsert_pr_requires_a_base_on_detached_head(git, gh, monkeypatch)[source]ΒΆ
tests.test_pr.test_upsert_pr_falls_back_to_the_event_default_branch(git, gh, monkeypatch, tmp_path)[source]ΒΆ

A detached checkout takes its base from the CI event payload.

tests.test_pr.test_upsert_pr_rejects_a_base_missing_from_the_remote(git, gh)[source]ΒΆ
tests.test_pr.test_upsert_pr_without_changes_or_branch_does_nothing(git, gh)[source]ΒΆ

The quietest path: nothing to publish and nothing to retire.

tests.test_pr.test_upsert_pr_retires_branch_and_pr_when_changes_evaporate(git, gh)[source]ΒΆ

The path a skipped action step could never reach.

tests.test_pr.test_upsert_pr_deletes_an_orphan_branch_with_no_open_pr(git, gh)[source]ΒΆ
tests.test_pr.test_upsert_pr_creates_branch_and_pr(git, gh)[source]ΒΆ
tests.test_pr.test_upsert_pr_updates_an_existing_pr_and_leases_the_push(git, gh)[source]ΒΆ
tests.test_pr.test_upsert_pr_skips_the_push_when_the_branch_already_matches(git, gh)[source]ΒΆ

The check that keeps an unchanged job from re-triggering every workflow.

tests.test_pr.test_upsert_pr_keeps_a_concurrent_push_on_its_base(git, gh)[source]ΒΆ

A run losing its lease to one built on the same base keeps that push.

tests.test_pr.test_upsert_pr_pushes_again_over_a_concurrent_push_on_an_older_base(git, gh)[source]ΒΆ

A run losing its lease to one built on an older base pushes once more.

tests.test_pr.test_upsert_pr_restores_the_checkout_when_the_push_fails(git, gh)[source]ΒΆ
tests.test_pr.test_upsert_pr_survives_a_refused_label_or_assignee(git, gh)[source]ΒΆ

github-actions[bot] cannot be assigned, and that must not lose the PR.

tests.test_pr.test_upsert_pr_opens_against_an_explicit_base_from_a_detached_head(git, gh)[source]ΒΆ

fix-changelog and bump-version check out a raw SHA, not a branch.

tests.test_pr.test_upsert_pr_carries_commits_the_job_made_itself(git, gh)[source]ΒΆ

prepare-release commits freeze and unfreeze; both must reach the PR.

tests.test_pr.test_upsert_pr_replays_carried_commits_onto_a_moved_base(git, gh)[source]ΒΆ
tests.test_pr.test_upsert_pr_publishes_anyway_when_the_replay_conflicts(git, gh)[source]ΒΆ

A branch on a stale base still opens a usable PR; the next run converges.

tests.test_pr.test_upsert_pr_skips_the_replay_when_history_is_unrelatable(git, gh)[source]ΒΆ

A shallow clone answers neither yes nor no, and must not be rebased blind.

tests.test_pr.test_upsert_pr_creates_a_draft_when_asked(git, gh)[source]ΒΆ
tests.test_pr.test_upsert_pr_puts_a_readied_pr_back_into_draft(git, gh)[source]ΒΆ

draft is re-applied on update, matching the action’s always-true mode.

tests.test_pr.test_upsert_pr_leaves_an_already_draft_pr_alone(git, gh)[source]ΒΆ
tests.test_pr.cli_upsert(monkeypatch)[source]ΒΆ

Capture what the pr-sync command hands to upsert_pr.

tests.test_pr.test_pr_sync_cli_resolves_everything_from_the_template(cli_upsert)[source]ΒΆ

One flag yields branch, labels, draft, title, body and commit message.

tests.test_pr.test_pr_sync_cli_renders_the_upgrade_template(tmp_path, monkeypatch)[source]ΒΆ

The init --upgrade step outputs reach the pull request title and body.

tests.test_pr.test_pr_sync_cli_reads_draft_from_frontmatter(cli_upsert)[source]ΒΆ
tests.test_pr.test_pr_sync_cli_explicit_labels_override_frontmatter(cli_upsert)[source]ΒΆ
tests.test_pr.test_pr_sync_cli_validates_its_inputs(cli_upsert, args, error)[source]ΒΆ
tests.test_pr.test_pr_sync_cli_draft_flag_overrides_frontmatter(cli_upsert)[source]ΒΆ

--draft holds a pull request in draft that its template opens ready.

tests.test_pr.test_pr_sync_cli_explicit_trio_names_the_pull_request(monkeypatch)[source]ΒΆ

Without a template, the trio and --branch reach the sync as given.

tests.test_pr.test_pr_sync_cli_names_the_missing_template_argument(monkeypatch)[source]ΒΆ

A template argument nothing supplies is a usage error, and nothing syncs.

tests.test_pr.test_carry_pr_branch_paths_outcomes(monkeypatch, tip, restored, expected)[source]ΒΆ

Work travels only when the branch exists and carries the named file.

Every other outcome is the first run of a fresh accrual, which must be a silent no-op rather than a failure: the branch is legitimately gone after each merge.

tests.test_pr.test_carry_pr_branch_paths_restores_the_fetched_tip(monkeypatch)[source]ΒΆ

The restore reads the tip just fetched, never the branch name.

A branch name resolves against whatever remote-tracking ref the checkout held before the fetch, which on a CI clone is frequently nothing at all.

tests.test_pr.test_automation_branches_are_the_pull_request_templates_and_bump_branches()[source]ΒΆ

Every template fronting a pull request names a branch; the others do not.

tests.test_pr.test_behind_by_reads_the_comparison()[source]ΒΆ

The count comes off the compare endpoint, None when it cannot be read.

tests.test_pr.test_list_automation_prs_keeps_the_automation_branches_only()[source]ΒΆ

A hand-made branch is left out, and each kept row learns its lag.

tests.test_pr.test_release_pr_reads_the_open_pull_request_and_its_lag()[source]ΒΆ

A closed or missing release PR reads as none; an open one carries its lag.