예제 #1
0
    def testDistribution(self):
        """aptsources: Test distribution detection."""
        apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/"
                           "sources.list.testDistribution")
        sources = aptsources.sourceslist.SourcesList(True, self.templates)
        distro = aptsources.distro.get_distro(id="Ubuntu",
                                              codename="bionic",
                                              description="Ubuntu 18.04 LTS",
                                              release="18.04")
        distro.get_sources(sources)
        # test if all suits of the current distro were detected correctly
        dist_templates = set()
        for s in sources:
            if s.template:
                dist_templates.add(s.template.name)
        #print dist_templates
        for d in ("hardy", "hardy-security", "hardy-updates", "intrepid",
                  "hardy-backports"):
            self.assertTrue(d in dist_templates)
        # test enable
        comp = "restricted"
        distro.enable_component(comp)
        found = {}
        for entry in sources:
            if (entry.type == "deb"
                    and entry.uri == "http://de.archive.ubuntu.com/ubuntu/"
                    and "edgy" in entry.dist):
                for c in entry.comps:
                    if c == comp:
                        if entry.dist not in found:
                            found[entry.dist] = 0
                        found[entry.dist] += 1
        #print "".join([s.str() for s in sources])
        for key in found:
            self.assertEqual(found[key], 1)

        # add a not-already available component
        comp = "multiverse"
        distro.enable_component(comp)
        found = {}
        for entry in sources:
            if (entry.type == "deb" and entry.template
                    and entry.template.name == "edgy"):
                for c in entry.comps:
                    if c == comp:
                        if entry.dist not in found.has_key:
                            found[entry.dist] = 0
                        found[entry.dist] += 1
        #print "".join([s.str() for s in sources])
        for key in found:
            self.assertEqual(found[key], 1)
예제 #2
0
    def testDistribution(self):
        """aptsources: Test distribution detection."""
        apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/"
                           "sources.list.testDistribution")
        sources = aptsources.sourceslist.SourcesList(True, self.templates)
        distro = aptsources.distro.get_distro(id="Ubuntu")
        distro.get_sources(sources)
        # test if all suits of the current distro were detected correctly
        dist_templates = set()
        for s in sources:
            if s.template:
                dist_templates.add(s.template.name)
        #print dist_templates
        for d in ("hardy", "hardy-security", "hardy-updates", "intrepid",
                  "hardy-backports"):
            self.assertTrue(d in dist_templates)
        # test enable
        comp = "restricted"
        distro.enable_component(comp)
        found = {}
        for entry in sources:
            if (entry.type == "deb" and
                    entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and
                    "edgy" in entry.dist):
                for c in entry.comps:
                    if c == comp:
                        if entry.dist not in found:
                            found[entry.dist] = 0
                        found[entry.dist] += 1
        #print "".join([s.str() for s in sources])
        for key in found:
            self.assertEqual(found[key], 1)

        # add a not-already available component
        comp = "multiverse"
        distro.enable_component(comp)
        found = {}
        for entry in sources:
            if (entry.type == "deb" and
                    entry.template and
                    entry.template.name == "edgy"):
                for c in entry.comps:
                    if c == comp:
                        if entry.dist not in found.has_key:
                            found[entry.dist] = 0
                        found[entry.dist] += 1
        #print "".join([s.str() for s in sources])
        for key in found:
            self.assertEqual(found[key], 1)
    def testDistribution(self):
        apt_pkg.config.set("Dir::Etc::sourcelist",
                           self.sources_list + ".testDistribution")
        sources = aptsources.sourceslist.SourcesList()
        distro = aptsources.distro.get_distro(codename="edgy")
        distro.get_sources(sources)
        # test if all suits of the current distro were detected correctly
        dist_templates = set()
        for s in sources:
            if s.template:
                dist_templates.add(s.template.name)
        #print(dist_templates)
        for d in ["edgy", "edgy-security", "edgy-updates", "hoary"]:
            self.assertTrue(d in dist_templates)
        # test enable
        comp = "restricted"
        distro.enable_component(comp)
        found = {}
        for entry in sources:
            if (entry.type == "deb"
                    and entry.uri == "http://de.archive.ubuntu.com/ubuntu/"
                    and "edgy" in entry.dist):
                for c in entry.comps:
                    if c == comp:
                        if entry.dist not in found:
                            found[entry.dist] = 0
                        found[entry.dist] += 1
        #print("".join([s.str() for s in sources]))
        for key in found:
            self.assertEqual(found[key], 1)

        # add a not-already available component
        comp = "multiverse"
        distro.enable_component(comp)
        found = {}
        for entry in sources:
            if (entry.type == "deb" and entry.template
                    and entry.template.name == "edgy"):
                for c in entry.comps:
                    if c == comp:
                        if entry.dist not in found:
                            found[entry.dist] = 0
                        found[entry.dist] += 1
        #print("".join([s.str() for s in sources]))
        for key in found:
            self.assertEqual(found[key], 1)
예제 #4
0
 def test_enable_component(self):
     target = "./data/aptsources/sources.list.enable_comps"
     line = "deb http://archive.ubuntu.com/ubuntu lucid main\n"
     with open(target, "w") as target_file:
         target_file.write(line)
     apt_pkg.config.set("Dir::Etc::sourcelist", target)
     sources = aptsources.sourceslist.SourcesList(True, self.templates)
     distro = aptsources.distro.get_distro(id="Ubuntu")
     # make sure we are using the right distro
     distro.codename = "lucid"
     distro.id = "Ubuntu"
     distro.release = "10.04"
     # and get the sources
     distro.get_sources(sources)
     # test enable_component
     comp = "multiverse"
     distro.enable_component(comp)
     comps = set()
     for entry in sources:
         comps = comps.union(set(entry.comps))
     self.assertTrue("multiverse" in comps)
     self.assertTrue("universe" in comps)
예제 #5
0
 def test_enable_component(self):
     target = "./data/aptsources/sources.list.enable_comps"
     line = "deb http://archive.ubuntu.com/ubuntu lucid main\n"
     with open(target, "w") as target_file:
         target_file.write(line)
     apt_pkg.config.set("Dir::Etc::sourcelist", target)
     sources = aptsources.sourceslist.SourcesList(True, self.templates)
     distro = aptsources.distro.get_distro(id="Ubuntu")
     # make sure we are using the right distro
     distro.codename = "lucid"
     distro.id = "Ubuntu"
     distro.release = "10.04"
     # and get the sources
     distro.get_sources(sources)
     # test enable_component
     comp = "multiverse"
     distro.enable_component(comp)
     comps = set()
     for entry in sources:
         comps = comps.union(set(entry.comps))
     self.assertTrue("multiverse" in comps)
     self.assertTrue("universe" in comps)
#! /usr/bin/python

import aptsources.distro
from aptsources.sourceslist import SourcesList, SourceEntry

list=SourcesList()
distro=aptsources.distro.get_distro()
distro.get_sources(list)
distro.enable_component("universe")
distro.enable_component("multiverse")
list.save()