tests.test_release_sync module¶

Tests for repomatic.github.release_sync: changelog-to-release-notes sync.

tests.test_release_sync.test_build_expected_body()[source]¶

Verbatim extraction from changelog.

tests.test_release_sync.test_build_expected_body_with_admonition()[source]¶

Extraction preserves admonitions when they appear in the changes group.

tests.test_release_sync.test_build_expected_body_admonition_override()[source]¶

Override replaces the changelog’s availability admonition.

tests.test_release_sync.test_build_expected_body_admonition_override_no_original()[source]¶

Override injects an admonition where none existed in the changelog.

tests.test_release_sync.test_build_expected_body_editorial_only()[source]¶

Version with only editorial admonition returns non-empty body.

tests.test_release_sync.test_build_expected_body_missing_version()[source]¶

Returns empty string for a missing version.

tests.test_release_sync.test_build_expected_body_includes_all_elements()[source]¶

The github-releases template includes all elements like release-notes.

tests.test_release_sync.test_build_expected_body_decomposes_elements()[source]¶

Verifies the decompose → template path produces correct output.

The github-releases template appends a full changelog link.

tests.test_release_sync.test_build_draft_body_bakes_the_pypi_admonition()[source]¶

A PyPI project’s draft carries its availability admonition from the start.

The draft is created before fix-changelog writes the admonition into the changelog, which is the race the bake closes.

tests.test_release_sync.test_build_draft_body_falls_back_to_the_plain_notes()[source]¶

A project not on PyPI gets the changelog section as it is.

tests.test_release_sync.RELEASE_SECTIONS = {'1.0.0': '## [`1.0.0` (2026-01-15)](https://github.com/user/repo/compare/v0.9.0...v1.0.0)\n\n- Initial release.\n', '1.1.0': '## [`1.1.0` (2026-02-10)](https://github.com/user/repo/compare/v1.0.0...v1.1.0)\n\n- Second release.\n'}¶

Released changelog sections, newest first, keyed by their version.

tests.test_release_sync.test_draft_release_notes_word_availability_like_the_changelog(released, first)[source]¶

The draft release body states availability the way the changelog will.

lint-changelog --fix writes the first version wording into the section of a project’s first release. The draft body is baked before that fix runs, so it has to reach the same wording on its own, or the two disagree.

tests.test_release_sync.test_build_pypi_body_needs_a_repository()[source]¶

A changelog naming no repository cannot link the GitHub release.

tests.test_release_sync.test_normalize_body(text, expected)[source]¶

Whitespace normalization edge cases.

tests.test_release_sync.changelog_path(tmp_path)[source]¶

A changelog file on disk holding SAMPLE_CHANGELOG.

tests.test_release_sync.expected_body(version)[source]¶

The release body sync_github_releases would render for version.

Return type:

str

tests.test_release_sync.run_sync(changelog_path, releases, *, dry_run=True, edit_result=None)[source]¶

Drive sync_github_releases against canned GitHub state.

Parameters:
  • changelog_path – The changelog the expected bodies are derived from.

  • releases – Version to GitHubRelease, as the API would return them.

  • dry_run – Passed straight through to the command.

  • edit_result – When set, edit_release_notes is patched to return it and the mock is handed back beside the result so a caller can assert on the calls. Left None, no mutation seam is installed.

Returns:

The sync result, or (result, edit_mock) when edit_result is set.

tests.test_release_sync.test_sync_all_in_sync(changelog_path)[source]¶

No updates when all bodies match.

tests.test_release_sync.test_sync_detects_drift(changelog_path)[source]¶

Flags releases with different bodies in dry-run.

tests.test_release_sync.test_sync_dry_run_no_mutations(changelog_path)[source]¶

Dry-run doesn’t call gh release edit.

tests.test_release_sync.test_sync_live_updates(changelog_path)[source]¶

Live mode calls gh release edit with correct args.

tests.test_release_sync.test_sync_missing_changelog_section(changelog_path)[source]¶

A GitHub release with no changelog section is never iterated.

tests.test_release_sync.test_sync_counts_an_empty_changelog_section(tmp_path)[source]¶

A released version whose section holds nothing is counted, not compared.

tests.test_release_sync.test_sync_without_releases_to_compare(changelog_path, repo_url, answer)[source]¶

A repository off GitHub, an unhealthy API or no release syncs nothing.

tests.test_release_sync.test_sync_live_failure(changelog_path)[source]¶

Records failure when gh release edit fails.

tests.test_release_sync.test_sync_live_error_moves_on_to_the_next_release(changelog_path)[source]¶

A failed edit counts against its release, and the sync goes on.

edit_release_notes raises on any failure but a missing release. Left uncaught, one transient error would abort the run and leave every release after it drifted.

tests.test_release_sync.test_render_sync_report_dry_run()[source]¶

Report format for dry-run mode.

tests.test_release_sync.test_render_sync_report_live()[source]¶

Report format for live mode.

tests.test_release_sync.test_sync_github_releases_command_honors_its_switch(tmp_path, monkeypatch, setting, synced)[source]¶

github-releases.sync = false reads and writes no release.