From 30a4f525e1ef360bfba25e72ce3679fc6c9df81e Mon Sep 17 00:00:00 2001 From: Jun Aruga Date: Thu, 5 Feb 2026 12:23:27 +0000 Subject: [PATCH] Add ContextValue version_cmp method tests for CentOS Stream and RHEL Add the test_version_cmp_centos_stream and test_version_cmp_rhel. The main purpose to add these tests are to make sure the `distro: centos-stream-rawhide` and `distro: rhel-10.rawhide` work. --- tests/unit/test_context.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/unit/test_context.py b/tests/unit/test_context.py index b26e375..ab1010b 100644 --- a/tests/unit/test_context.py +++ b/tests/unit/test_context.py @@ -480,6 +480,40 @@ def test_version_cmp_fedora(self): assert frawhide.version_cmp(f33) > 0 assert f33.version_cmp(frawhide) < 0 + def test_version_cmp_centos_stream(self): + """ + CentOS Stream comparison + """ + + cs9 = ContextValue("centos-stream-9") + csrawhide = ContextValue("centos-stream-rawhide") + + assert cs9.version_cmp(ContextValue("centos-stream-9")) == 0 + assert cs9.version_cmp(ContextValue("centos-stream-8")) > 0 + assert cs9.version_cmp(ContextValue("centos-stream-10")) < 0 + + assert csrawhide.version_cmp(ContextValue("centos-stream-rawhide")) == 0 + assert csrawhide.version_cmp(cs9) > 0 + assert cs9.version_cmp(csrawhide) < 0 + + def test_version_cmp_rhel(self): + """ + RHEL comparison + """ + + rhel9_1 = ContextValue("rhel-9.1") + rhel9_rawhide = ContextValue("rhel-9.rawhide") + + assert rhel9_1.version_cmp(ContextValue("rhel-9.1")) == 0 + assert rhel9_1.version_cmp(ContextValue("rhel-9")) == 0 + assert rhel9_1.version_cmp(ContextValue("rhel-9.0")) > 0 + assert rhel9_1.version_cmp(ContextValue("rhel-9.2")) < 0 + assert rhel9_1.version_cmp(ContextValue("rhel-10")) < 0 + + assert rhel9_rawhide.version_cmp(ContextValue("rhel-9.rawhide")) == 0 + assert rhel9_rawhide.version_cmp(rhel9_1) > 0 + assert rhel9_1.version_cmp(rhel9_rawhide) < 0 + def test_prints(self): f33 = ContextValue("fedora-33") str(f33)