summaryrefslogtreecommitdiffstats
path: root/packages/tests.py
blob: 3a460865c8af80cc6d6c8ba3458c1256dcaf880b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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: