aboutsummaryrefslogtreecommitdiff
path: root/scripts/test_changelog.py
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-04-07 21:32:46 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-04-07 21:32:46 +0300
commit96f88c70e69d587e9c5821ea2777677c5fb1264c (patch)
treef36f0f5ea3bb9b302351a30fac29be5b54619c3d /scripts/test_changelog.py
parent7c12feed7e8f2862dbbb5e7bd082967d0613b714 (diff)
feat: add release state verification
Diffstat (limited to 'scripts/test_changelog.py')
-rw-r--r--scripts/test_changelog.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/scripts/test_changelog.py b/scripts/test_changelog.py
index 6821dc38..10af5c47 100644
--- a/scripts/test_changelog.py
+++ b/scripts/test_changelog.py
@@ -6,8 +6,10 @@ import unittest
from scripts.changelog import (
ChangelogError,
build_latest_json,
+ canonicalize_manifest,
default_release_assets,
ensure_manifest_is_outdated,
+ ensure_manifest_matches_expected,
extract_section_body,
manifest_from_release_payload,
prepare_release,
@@ -129,6 +131,72 @@ class ChangelogScriptTests(unittest.TestCase):
def test_ensure_manifest_is_outdated_allows_older_version(self) -> None:
ensure_manifest_is_outdated({"version": "0.1.0"}, "0.1.1")
+ def test_canonicalize_manifest_requires_all_asset_targets(self) -> None:
+ with self.assertRaisesRegex(ChangelogError, "missing asset URL for macos-aarch64"):
+ canonicalize_manifest(
+ {
+ "version": "0.1.1",
+ "notes": "### Fixed\n- One",
+ "assets": {
+ "linux-x86_64": "https://example.com/linux-x86_64",
+ "linux-aarch64": "https://example.com/linux-aarch64",
+ "macos-x86_64": "https://example.com/macos-x86_64",
+ },
+ },
+ "test manifest",
+ )
+
+ def test_ensure_manifest_matches_expected_normalizes_whitespace(self) -> None:
+ actual = {
+ "version": "v0.1.1",
+ "notes": "\n### Fixed\n- One\n",
+ "assets": {
+ "linux-x86_64": " https://example.com/linux-x86_64 ",
+ "linux-aarch64": "https://example.com/linux-aarch64",
+ "macos-x86_64": "https://example.com/macos-x86_64",
+ "macos-aarch64": "https://example.com/macos-aarch64",
+ },
+ }
+ expected = {
+ "version": "0.1.1",
+ "notes": "### Fixed\n- One",
+ "assets": {
+ "linux-x86_64": "https://example.com/linux-x86_64",
+ "linux-aarch64": "https://example.com/linux-aarch64",
+ "macos-x86_64": "https://example.com/macos-x86_64",
+ "macos-aarch64": "https://example.com/macos-aarch64",
+ },
+ }
+
+ canonical = ensure_manifest_matches_expected(actual, expected, "test manifest")
+ self.assertEqual(canonical, expected)
+
+ def test_ensure_manifest_matches_expected_rejects_different_notes(self) -> None:
+ with self.assertRaisesRegex(ChangelogError, "does not match the published GitHub release manifest"):
+ ensure_manifest_matches_expected(
+ {
+ "version": "0.1.1",
+ "notes": "### Fixed\n- Different",
+ "assets": {
+ "linux-x86_64": "https://example.com/linux-x86_64",
+ "linux-aarch64": "https://example.com/linux-aarch64",
+ "macos-x86_64": "https://example.com/macos-x86_64",
+ "macos-aarch64": "https://example.com/macos-aarch64",
+ },
+ },
+ {
+ "version": "0.1.1",
+ "notes": "### Fixed\n- One",
+ "assets": {
+ "linux-x86_64": "https://example.com/linux-x86_64",
+ "linux-aarch64": "https://example.com/linux-aarch64",
+ "macos-x86_64": "https://example.com/macos-x86_64",
+ "macos-aarch64": "https://example.com/macos-aarch64",
+ },
+ },
+ "test manifest",
+ )
+
if __name__ == "__main__":
unittest.main()