diff options
Diffstat (limited to 'tests/test_aptsources.py')
| -rw-r--r-- | tests/test_aptsources.py | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py index 75dd91c1..f174bd41 100644 --- a/tests/test_aptsources.py +++ b/tests/test_aptsources.py @@ -40,11 +40,11 @@ class TestAptSources(unittest.TestCase): apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" "sources.list") sources = aptsources.sourceslist.SourcesList(True, self.templates) - self.assertEqual(len(sources.list), 9) + self.assertEqual(len(sources.list), 10) # test load sources.list = [] sources.load("data/aptsources/sources.list") - self.assertEqual(len(sources.list), 9) + self.assertEqual(len(sources.list), 10) def testSourcesListAdding(self): """aptsources: Test additions to sources.list""" @@ -70,7 +70,6 @@ class TestAptSources(unittest.TestCase): ["main"], architectures=["amd64", "i386"]) self.assertTrue(sources.list == before.list) - # test to add something new: multiverse sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", "edgy", @@ -78,9 +77,9 @@ class TestAptSources(unittest.TestCase): found = False for entry in sources: if (entry.type == "deb" and - entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and - entry.dist == "edgy" and - "multiverse" in entry.comps): + entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and + entry.dist == "edgy" and + "multiverse" in entry.comps): found = True self.assertTrue(found) @@ -91,10 +90,10 @@ class TestAptSources(unittest.TestCase): found = False for entry in sources: if (entry.type == "deb" and - entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and - entry.dist == "natty" and - entry.architectures == [] and - "multiverse" in entry.comps): + entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and + entry.dist == "natty" and + entry.architectures == [] and + "multiverse" in entry.comps): found = True self.assertTrue(found) @@ -105,10 +104,10 @@ class TestAptSources(unittest.TestCase): found = False for entry in sources: if (entry.type == "deb" and - entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and - entry.dist == "natty" and - set(entry.architectures) == set(["amd64", "i386"]) and - set(entry.comps) == set(["main", "universe"])): + entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and + entry.dist == "natty" and + set(entry.architectures) == set(["amd64", "i386"]) and + set(entry.comps) == set(["main", "universe"])): found = True self.assertTrue(found) # test to add something new: multiverse *and* @@ -121,8 +120,8 @@ class TestAptSources(unittest.TestCase): found_something = 0 for entry in sources: if (entry.type == "deb" and - entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and - entry.dist == "edgy"): + entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and + entry.dist == "edgy"): for c in entry.comps: if c == "universe": found_universe += 1 @@ -140,7 +139,6 @@ class TestAptSources(unittest.TestCase): 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 not s.template: self.fail("source entry '%s' has no matcher" % s) @@ -151,17 +149,32 @@ class TestAptSources(unittest.TestCase): apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" "sources.list") sources = aptsources.sourceslist.SourcesList(True, self.templates) - - assert sources.list[8].invalid == False + assert not sources.list[8].invalid assert sources.list[8].type == "deb" assert sources.list[8].architectures == ["amd64", "i386"] assert sources.list[8].uri == "http://de.archive.ubuntu.com/ubuntu/" assert sources.list[8].dist == "natty" assert sources.list[8].comps == ["main"] assert sources.list[8].line.strip() == str(sources.list[8]) + assert sources.list[8].trusted is None + + def testMultipleOptions(self): + """aptsources: Test multi-arch parsing""" + + apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" + "sources.list") + sources = aptsources.sourceslist.SourcesList(True, self.templates) + assert sources.list[9].invalid is False + assert sources.list[9].type == "deb" + assert sources.list[9].architectures == ["amd64", "i386"] + self.assertEqual( + sources.list[9].uri, "http://de.archive.ubuntu.com/ubuntu/") + assert sources.list[9].dist == "natty" + assert sources.list[9].comps == ["main"] + assert sources.list[9].trusted + assert sources.list[9].line.strip() == str(sources.list[9]) def test_enable_component(self): - from subprocess import Popen, PIPE target = "./data/aptsources/sources.list.enable_comps" line = "deb http://archive.ubuntu.com/ubuntu lucid main\n" with open(target, "w") as target_file: @@ -183,7 +196,7 @@ class TestAptSources(unittest.TestCase): comps = comps.union(set(entry.comps)) self.assertTrue("multiverse" in comps) self.assertTrue("universe" in comps) - + def testDistribution(self): """aptsources: Test distribution detection.""" apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" @@ -206,11 +219,11 @@ class TestAptSources(unittest.TestCase): found = {} for entry in sources: if (entry.type == "deb" and - entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and - "edgy" in entry.dist): + entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and + "edgy" in entry.dist): for c in entry.comps: if c == comp: - if not entry.dist in found: + if entry.dist not in found: found[entry.dist] = 0 found[entry.dist] += 1 #print "".join([s.str() for s in sources]) @@ -223,11 +236,11 @@ class TestAptSources(unittest.TestCase): found = {} for entry in sources: if (entry.type == "deb" and - entry.template and - entry.template.name == "edgy"): + entry.template and + entry.template.name == "edgy"): for c in entry.comps: if c == comp: - if not entry.dist in found.has_key: + if entry.dist not in found.has_key: found[entry.dist] = 0 found[entry.dist] += 1 #print "".join([s.str() for s in sources]) |
