From ff8a60db854f628aee6abb73de59c59e3d2d8d22 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Thu, 30 Nov 2023 10:52:57 +0100 Subject: [PATCH] fix version hierarchy in readme and add a test, for good measure --- README.md | 2 +- tests/test_client.py | 9 +++++++++ tests/test_common.py | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 20b3310..1496c40 100644 --- a/README.md +++ b/README.md @@ -157,7 +157,7 @@ If the app checks the alpha channel (`'a'`), it finds `2.0.0a3`. Just to be clear: `tufup` assumes a typical linear release history without branching, so ```none -0.0 < 0.1a < 0.1b < 0.1rc < 0.1rc0 < 0.1rc1 < 0.1 < ... +0.0 < 0.1a < 0.1b < 0.1rc < 0.1rc1 < 0.1 < ... ``` ## Migrating from other update frameworks diff --git a/tests/test_client.py b/tests/test_client.py index 482652c..ee2c0b3 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -6,6 +6,7 @@ import unittest from unittest.mock import Mock, patch +import packaging.version from requests.auth import HTTPBasicAuth import tuf.api.exceptions from tuf.ngclient import TargetFile @@ -213,6 +214,14 @@ def test__apply_updates(self): client._apply_updates(install=mock_install, skip_confirmation=True) mock_install.assert_called() + def test_version_comparison(self): + # verify assumed version hierarchy + v = packaging.version.Version + self.assertTrue( + v('0.0.0') < v('0.1a') < v('0.1b') < v('0.1rc') < v('0.1rc1') < v('0.1') + ) + self.assertEqual(v('0.1rc'), v('0.1rc0')) + class AuthRequestsFetcherTests(unittest.TestCase): def setUp(self) -> None: diff --git a/tests/test_common.py b/tests/test_common.py index 86a743d..90e0175 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -8,7 +8,7 @@ from tufup.common import Patcher, TargetMeta -class TestTargetMeta(TempDirTestCase): +class TargetMetaTests(TempDirTestCase): def test_init_whitespace(self): for kwargs in [ dict(target_path='w h i t e s p a c e-1.2.3.tar.gz'),