summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-12-28 00:04:14 +0100
committerDan McGee <dan@archlinux.org>2012-12-28 00:04:20 +0100
commita993295002ad36b40c49619e892de6e78aa00c06 (patch)
treeb5a28f0bc11062118f0be41758941a7e741c6a81
parente68a5073a6e8b9473f726734e0b51fdb0a42c14b (diff)
downloadarchweb-a993295002ad36b40c49619e892de6e78aa00c06.tar.gz
archweb-a993295002ad36b40c49619e892de6e78aa00c06.tar.xz
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>
-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 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: