Skip to content

Commit 30a4f52

Browse files
committed
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.
1 parent 39af408 commit 30a4f52

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

tests/unit/test_context.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,40 @@ def test_version_cmp_fedora(self):
480480
assert frawhide.version_cmp(f33) > 0
481481
assert f33.version_cmp(frawhide) < 0
482482

483+
def test_version_cmp_centos_stream(self):
484+
"""
485+
CentOS Stream comparison
486+
"""
487+
488+
cs9 = ContextValue("centos-stream-9")
489+
csrawhide = ContextValue("centos-stream-rawhide")
490+
491+
assert cs9.version_cmp(ContextValue("centos-stream-9")) == 0
492+
assert cs9.version_cmp(ContextValue("centos-stream-8")) > 0
493+
assert cs9.version_cmp(ContextValue("centos-stream-10")) < 0
494+
495+
assert csrawhide.version_cmp(ContextValue("centos-stream-rawhide")) == 0
496+
assert csrawhide.version_cmp(cs9) > 0
497+
assert cs9.version_cmp(csrawhide) < 0
498+
499+
def test_version_cmp_rhel(self):
500+
"""
501+
RHEL comparison
502+
"""
503+
504+
rhel9_1 = ContextValue("rhel-9.1")
505+
rhel9_rawhide = ContextValue("rhel-9.rawhide")
506+
507+
assert rhel9_1.version_cmp(ContextValue("rhel-9.1")) == 0
508+
assert rhel9_1.version_cmp(ContextValue("rhel-9")) == 0
509+
assert rhel9_1.version_cmp(ContextValue("rhel-9.0")) > 0
510+
assert rhel9_1.version_cmp(ContextValue("rhel-9.2")) < 0
511+
assert rhel9_1.version_cmp(ContextValue("rhel-10")) < 0
512+
513+
assert rhel9_rawhide.version_cmp(ContextValue("rhel-9.rawhide")) == 0
514+
assert rhel9_rawhide.version_cmp(rhel9_1) > 0
515+
assert rhel9_1.version_cmp(rhel9_rawhide) < 0
516+
483517
def test_prints(self):
484518
f33 = ContextValue("fedora-33")
485519
str(f33)

0 commit comments

Comments
 (0)