]> git.ipfire.org Git - pakfire.git/commitdiff
tests: python: Add some simple tests for pakfire.version_compare()
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 5 Feb 2025 11:09:03 +0000 (11:09 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 5 Feb 2025 11:09:03 +0000 (11:09 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
tests/python/version_compare.py [new file with mode: 0755]

index 562f9429e89dcbafe3a9bcd80e2a138d9e58d24a..fff1b2a6905dcfcb2516f99269e563ab95d54163 100644 (file)
@@ -1226,7 +1226,8 @@ dist_check_SCRIPTS = \
        tests/python/archive.py \
        tests/python/ctx.py \
        tests/python/keys.py \
-       tests/python/package.py
+       tests/python/package.py \
+       tests/python/version_compare.py
 
 EXTRA_DIST += \
        tests/python/tests.py
diff --git a/tests/python/version_compare.py b/tests/python/version_compare.py
new file mode 100755 (executable)
index 0000000..e8d9326
--- /dev/null
@@ -0,0 +1,40 @@
+#!/usr/bin/python3
+###############################################################################
+#                                                                             #
+# Pakfire - The IPFire package management system                              #
+# Copyright (C) 2025 Pakfire development team                                 #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+import pakfire
+
+import tests
+
+class VersionCompareTest(tests.TestCase):
+       """
+               This tests the static version comparison functions
+       """
+       def test_equality(self):
+               self.assertTrue(pakfire.version_compare("a", "a") == 0)
+
+       def test_sorting(self):
+               self.assertTrue(pakfire.version_compare("a", "b") < 0)
+               self.assertTrue(pakfire.version_compare("b", "a") > 0)
+               self.assertTrue(pakfire.version_compare("a", "c") < 0)
+               self.assertTrue(pakfire.version_compare("c", "a") > 0)
+
+if __name__ == "__main__":
+       tests.main()