summaryrefslogtreecommitdiff
path: root/packages/tests.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-12-27 17:04:14 -0600
committerDan McGee <dan@archlinux.org>2012-12-27 17:04:20 -0600
commita993295002ad36b40c49619e892de6e78aa00c06 (patch)
treeb5a28f0bc11062118f0be41758941a7e741c6a81 /packages/tests.py
parente68a5073a6e8b9473f726734e0b51fdb0a42c14b (diff)
Add some more tests for ALPM API stuff
These are super-simple, but it is also trivial to test. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages/tests.py')
-rw-r--r--packages/tests.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/tests.py b/packages/tests.py
new file mode 100644
index 00000000..3a460865
--- /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: