summaryrefslogtreecommitdiff
path: root/tests/test_apt_cache.py
blob: 3c2961e199a0ef7214451a76ce2a748e8baeafea (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
28
29
30
31
32
33
34
#!/usr/bin/python
#
# Copyright (C) 2010 Julian Andres Klode <jak@debian.org>
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.
"""Unit tests for verifying the correctness of check_dep, etc in apt_pkg."""
import unittest

import apt


class TestAptCache(unittest.TestCase):
    """ test the apt cache """

    def testAptCache(self):
        """ simple test that iterates all packages and all dependencies """
        cache = apt.Cache()
        # number is not meaningful and just need to be "big enough", 
        # the important bit is the test against __len__
        self.assertTrue(len(cache) > 100)
        # go over the cache and all dependencies, just to see if
        # that is possible and does not crash
        for pkg in cache:
            if pkg.candidate:
                for or_dep in pkg.candidate.dependencies:
                    for dep in or_dep.or_dependencies:
                        name = dep.name
                        relation = dep.relation
                        preDepends = dep.pre_depend

if __name__ == "__main__":
    unittest.main()