Files
computer-playbook/tests/unit/utils/update/test_base.py
T
kevinveenbirkenbachandClaude Opus 5 5137465c6f style: delete every comment the comments-valid policy rejects
3529 invalid comments in 528 files, grandfathered in while the linter
only saw the working-tree diff. Removal ran through the linter's own
collectors, so detection and deletion cannot drift: a comment whose
opener line is blank before it and whose closer line is blank after it
loses all its lines, anything else loses only the comment region, and a
line left holding a bare delimiter goes with it.

Five files keep their comments behind a nocheck marker instead. Four are
upstream configs whose inline docs are upstream's own (mautrix, systemd
journald, nextcloud-oidc-login, MediaWiki). In littlejs the
commented-out entries ARE the deactivation mechanism for an example
tile, so deleting them would delete configuration.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-18 03:22:02 +02:00

58 lines
1.7 KiB
Python

from __future__ import annotations
import unittest
from utils.update.base import (
is_semver,
latest_semver,
version_depth,
version_flavor,
version_key,
)
class TestUpdateBase(unittest.TestCase):
def test_latest_semver_respects_depth(self) -> None:
tags = ["4", "4.5", "4.6", "4.5.1", "5"]
self.assertEqual(latest_semver(tags, 1), "5")
self.assertEqual(latest_semver(tags, 2), "4.6")
self.assertEqual(latest_semver(tags, 3), "4.5.1")
def test_is_semver_accepts_flavored_tag(self) -> None:
self.assertTrue(is_semver("5.4.5-php8.3-apache"))
self.assertTrue(is_semver("v1.2.3-alpha"))
self.assertFalse(is_semver("main-v1.77.3.dynamic_rates"))
self.assertFalse(is_semver("alpine"))
def test_version_key_and_depth_ignore_flavor(self) -> None:
self.assertEqual(version_key("5.4.5-php8.3-apache"), (5, 4, 5, 0))
self.assertEqual(version_depth("5.4.5-php8.3-apache"), 3)
self.assertEqual(version_flavor("5.4.5-php8.3-apache"), "-php8.3-apache")
self.assertEqual(version_flavor("5.4.5"), "")
def test_latest_semver_matches_flavor(self) -> None:
tags = [
"5.4.4-php8.3-apache",
"5.4.5-php8.3-apache",
"5.4.6-php8.3-apache",
"5.4.6-php8.4-apache",
"5.4.6-php8.3-fpm",
"5.4.7",
"alpine",
]
self.assertEqual(
latest_semver(tags, 3, "-php8.3-apache"),
"5.4.6-php8.3-apache",
)
self.assertEqual(
latest_semver(tags, 3, "-php8.4-apache"),
"5.4.6-php8.4-apache",
)
self.assertEqual(latest_semver(tags, 3, ""), "5.4.7")
if __name__ == "__main__":
unittest.main()