summaryrefslogtreecommitdiff
path: root/packages/tests.py
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-04-22 00:36:57 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-04-22 00:36:57 -0400
commitdf7a6aa620af6a165bdacd755757f8cb1179331c (patch)
tree384b4c62d1f50d8effb733d81d2a810666807624 /packages/tests.py
parent94f972bb892dbf9a86f089f1872ae6d849c0cd0e (diff)
parenta22557811a24b68ef85d4271787c48d8d1e4fc99 (diff)
Merge branch 'archweb-generic2'
Conflicts: README.BRANDING local_settings.py.example packages/templatetags/package_extras.py public/views.py releng/views.py settings.py sitestatic/archnavbar/archnavbar.css sitestatic/silhouette.png templates/base.html templates/packages/differences.html templates/packages/opensearch.xml templates/packages/search.html templates/public/donate.html templates/public/download.html templates/public/feeds.html templates/public/index.html urls.py
Diffstat (limited to 'packages/tests.py')
-rw-r--r--packages/tests.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/packages/tests.py b/packages/tests.py
new file mode 100644
index 00000000..bbe9f00e
--- /dev/null
+++ b/packages/tests.py
@@ -0,0 +1,46 @@
+import unittest
+
+from .alpm import AlpmAPI
+
+
+alpm = AlpmAPI()
+
+
+class AlpmTestCase(unittest.TestCase):
+
+ @unittest.skipUnless(alpm.available, "ALPM is unavailable")
+ def test_version(self):
+ version = alpm.version()
+ self.assertIsNotNone(version)
+ version = version.split('.')
+ # version is a 3-tuple, e.g., '7.0.2'
+ self.assertEqual(3, len(version))
+
+ @unittest.skipUnless(alpm.available, "ALPM is unavailable")
+ def test_vercmp(self):
+ self.assertEqual(0, alpm.vercmp("1.0", "1.0"))
+ self.assertEqual(1, alpm.vercmp("1.1", "1.0"))
+
+ @unittest.skipUnless(alpm.available, "ALPM is unavailable")
+ def test_compare_versions(self):
+ 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"))
+
+ def test_behavior_when_unavailable(self):
+ mock_alpm = AlpmAPI()
+ mock_alpm.available = False
+
+ self.assertIsNone(mock_alpm.version())
+ self.assertIsNone(mock_alpm.vercmp("1.0", "1.0"))
+ self.assertIsNone(mock_alpm.compare_versions("1.0", "=", "1.0"))
+
+
+# vim: set ts=4 sw=4 et: