From a993295002ad36b40c49619e892de6e78aa00c06 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 27 Dec 2012 17:04:14 -0600 Subject: Add some more tests for ALPM API stuff These are super-simple, but it is also trivial to test. Signed-off-by: Dan McGee --- packages/tests.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 packages/tests.py (limited to 'packages') diff --git a/packages/tests.py b/packages/tests.py new file mode 100644 index 0000000..3a46086 --- /dev/null +++ b/packages/tests.py @@ -0,0 +1,27 @@ +import unittest + +from .alpm import AlpmAPI + +class AlpmTestCase(unittest.TestCase): + def test_version(self): + alpm = AlpmAPI() + version = alpm.version() + self.assertIsNotNone(version) + version = version.split('.') + # version is a 3-tuple, e.g., '7.0.2' + self.assertEqual(3, len(version)) + + def test_compare_versions(self): + alpm = AlpmAPI() + self.assertTrue(alpm.compare_versions("1.0", "<=", "2.0")) + self.assertTrue(alpm.compare_versions("1.0", "<", "2.0")) + self.assertFalse(alpm.compare_versions("1.0", ">=", "2.0")) + self.assertFalse(alpm.compare_versions("1.0", ">", "2.0")) + self.assertTrue(alpm.compare_versions("1:1.0", ">", "2.0")) + self.assertFalse(alpm.compare_versions("1.0.2", ">=", "2.1.0")) + + self.assertTrue(alpm.compare_versions("1.0", "=", "1.0")) + self.assertTrue(alpm.compare_versions("1.0", "=", "1.0-1")) + self.assertFalse(alpm.compare_versions("1.0", "!=", "1.0")) + +# vim: set ts=4 sw=4 et: -- cgit v1.2.3-24-g4f1b