From 522d72a3abeacee8b6070481738f9c9edd0a6161 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sat, 9 Sep 2006 23:23:57 +0200 Subject: * UpdateManager/Common/aptsources.py: - fix "add_component" to correcly add components even under difficult conditions * tests/data/sources.list.testDistribution: - changed the sources.list to make it sufficiently difficult for aptsources * tests/test_aptsources.py: - added other testcase for add_component() --- tests/data/sources.list.testDistribution | 9 ++------- tests/test_aptsources.py | 31 +++++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/data/sources.list.testDistribution b/tests/data/sources.list.testDistribution index dd900645..031e4c51 100644 --- a/tests/data/sources.list.testDistribution +++ b/tests/data/sources.list.testDistribution @@ -1,14 +1,9 @@ -# comment 1 deb http://de.archive.ubuntu.com/ubuntu/ edgy main -# comment 2 deb http://de.archive.ubuntu.com/ubuntu/ edgy restricted -# comment 3 deb http://de.archive.ubuntu.com/ubuntu/ edgy universe -# comment 4 deb http://de.archive.ubuntu.com/ubuntu/ edgy-updates universe multiverse -# comment 5 +deb http://de.archive.ubuntu.com/ubuntu/ edgy-updates restricted deb http://de.archive.ubuntu.com/ubuntu/ edgy-security main -# comment 6 +deb http://de.archive.ubuntu.com/ubuntu/ edgy-security multiverse deb http://ftp.debian.org/debian sid main -# comment 7 deb http://de.archive.ubuntu.com/ubuntu/ breezy main \ No newline at end of file diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py index d5b5ff9f..1db99e3c 100644 --- a/tests/test_aptsources.py +++ b/tests/test_aptsources.py @@ -83,17 +83,36 @@ class TestAptSources(unittest.TestCase): distro.get_sources(sources) comp = "restricted" distro.enable_component(sources, comp) - found = 0 + found = {} for entry in sources: if (entry.type == "deb" and entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and - entry.dist == "edgy"): + "edgy" in entry.dist): + for c in entry.comps: + if c == comp: + if not found.has_key(entry.dist): + 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(sources, 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: - found += 1 - print "".join([s.str() for s in sources]) - self.assertEqual(found, 1) - + if not found.has_key(entry.dist): + 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) if __name__ == "__main__": unittest.main() -- cgit v1.2.3