summaryrefslogtreecommitdiff
path: root/tests/test_aptsources_ports.py
blob: 09d6e9d93e99fdb34b63ce2e3890eab6affc30b6 (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
35
36
37
38
39
40
41
#!/usr/bin/env python

import unittest

import os
import copy
import sys

sys.path.insert(0, "../")
import apt_pkg
import aptsources
import aptsources.sourceslist
import aptsources.distro


class TestAptSources(unittest.TestCase):

    def __init__(self, methodName):
        unittest.TestCase.__init__(self, methodName)
        apt_pkg.init()
        apt_pkg.Config.Set("APT::Architecture", "powerpc")
        apt_pkg.Config.Set("Dir::Etc", os.path.abspath("test-data-ports"))
        apt_pkg.Config.Set("Dir::Etc::sourceparts", "/xxx")

    def testMatcher(self):
        apt_pkg.Config.Set("Dir::Etc::sourcelist", "sources.list")
        sources = aptsources.sourceslist.SourcesList()
        distro = aptsources.distro.get_distro("Ubuntu", "hardy", "desc",
                                              "8.04")
        distro.get_sources(sources)
        # test if all suits of the current distro were detected correctly
        dist_templates = set()
        for s in sources:
            if not s.line.strip() or s.line.startswith("#"):
                continue
            if not s.template:
                self.fail("source entry '%s' has no matcher" % s)


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