From cbd822c9dfe8cf18d828bd558290f15775b4d837 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 17 Jul 2009 19:40:47 +0200 Subject: tests: First work on the new testsuite. The module tests.test_all will run all available tests. Each test placed herein must be using unittest and provide at least 1 test case. It must be prefixed with test_. --- tests/data/sources.list | 6 ------ tests/data/sources.list.testDistribution | 13 ------------- 2 files changed, 19 deletions(-) delete mode 100644 tests/data/sources.list delete mode 100644 tests/data/sources.list.testDistribution (limited to 'tests/data') diff --git a/tests/data/sources.list b/tests/data/sources.list deleted file mode 100644 index 5481d4f0..00000000 --- a/tests/data/sources.list +++ /dev/null @@ -1,6 +0,0 @@ -# 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 \ No newline at end of file diff --git a/tests/data/sources.list.testDistribution b/tests/data/sources.list.testDistribution deleted file mode 100644 index 0f40e85a..00000000 --- a/tests/data/sources.list.testDistribution +++ /dev/null @@ -1,13 +0,0 @@ -deb http://de.archive.ubuntu.com/ubuntu/ hardy main -deb http://de.archive.ubuntu.com/ubuntu/ hardy restricted -deb http://de.archive.ubuntu.com/ubuntu/ hardy universe -deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates universe multiverse -deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates restricted -deb http://de.archive.ubuntu.com/ubuntu/ hardy-security main -deb http://de.archive.ubuntu.com/ubuntu/ hardy-security multiverse -deb http://ftp.debian.org/debian sid main -deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy main -deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy-backports main -deb http://archive.ubuntu.com/ubuntu/ intrepid main -deb cdrom:[Ubuntu 8.10 _Intrepid Ibex_ - Alpha]/ intrepid main -deb cdrom:[Ubuntu 8.04 _Hardy Heron_] hardy main \ No newline at end of file -- cgit v1.2.3 From c88f6ea1f3d2cca1ff7f1a22f51318ea3f28c01f Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 17 Jul 2009 20:53:45 +0200 Subject: tests: Import more tests from tests/old. --- tests/__init__.py | 2 +- tests/data/aptsources/sources.list | 6 + .../data/aptsources/sources.list.testDistribution | 13 ++ tests/data/aptsources_ports/sources.list | 59 ++++++++ tests/old/data/sources.list | 6 - tests/old/data/sources.list.testDistribution | 13 -- tests/old/test-data-ports/sources.list | 59 -------- tests/old/test_aptsources.py | 151 -------------------- tests/old/test_aptsources_ports.py | 41 ------ tests/test_aptsources.py | 155 +++++++++++++++++++++ tests/test_aptsources_ports.py | 39 ++++++ tests/test_cache_invocation.py | 8 +- 12 files changed, 278 insertions(+), 274 deletions(-) create mode 100644 tests/data/aptsources/sources.list create mode 100644 tests/data/aptsources/sources.list.testDistribution create mode 100644 tests/data/aptsources_ports/sources.list delete mode 100644 tests/old/data/sources.list delete mode 100644 tests/old/data/sources.list.testDistribution delete mode 100644 tests/old/test-data-ports/sources.list delete mode 100644 tests/old/test_aptsources.py delete mode 100644 tests/old/test_aptsources_ports.py create mode 100644 tests/test_aptsources.py create mode 100644 tests/test_aptsources_ports.py (limited to 'tests/data') diff --git a/tests/__init__.py b/tests/__init__.py index 8b137891..792d6005 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +1 @@ - +# diff --git a/tests/data/aptsources/sources.list b/tests/data/aptsources/sources.list new file mode 100644 index 00000000..5481d4f0 --- /dev/null +++ b/tests/data/aptsources/sources.list @@ -0,0 +1,6 @@ +# 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 \ No newline at end of file diff --git a/tests/data/aptsources/sources.list.testDistribution b/tests/data/aptsources/sources.list.testDistribution new file mode 100644 index 00000000..4ff0fae6 --- /dev/null +++ b/tests/data/aptsources/sources.list.testDistribution @@ -0,0 +1,13 @@ +deb http://de.archive.ubuntu.com/ubuntu/ hardy main +deb http://de.archive.ubuntu.com/ubuntu/ hardy restricted +deb http://de.archive.ubuntu.com/ubuntu/ hardy universe +deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates universe multiverse +deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates restricted +deb http://de.archive.ubuntu.com/ubuntu/ hardy-security main +deb http://de.archive.ubuntu.com/ubuntu/ hardy-security multiverse +deb http://ftp.debian.org/debian sid main +deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy main +deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy-backports main +deb http://archive.ubuntu.com/ubuntu/ intrepid main +deb cdrom:[Ubuntu 8.10 _Intrepid Ibex_ - Alpha]/ intrepid main +deb cdrom:[Ubuntu 8.04 _Hardy Heron_] hardy main diff --git a/tests/data/aptsources_ports/sources.list b/tests/data/aptsources_ports/sources.list new file mode 100644 index 00000000..a6b2f6ed --- /dev/null +++ b/tests/data/aptsources_ports/sources.list @@ -0,0 +1,59 @@ +# +# deb cdrom:[Ubuntu-Server 8.04.1 _Hardy Heron_ - Release powerpc (20080703)]/ hardy main restricted + +# deb cdrom:[Ubuntu-Server 8.04.1 _Hardy Heron_ - Release powerpc (20080703)]/ hardy main restricted +# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to +# newer versions of the distribution. + +deb http://ports.ubuntu.com/ubuntu-ports/ hardy main restricted +deb-src http://archive.ubuntu.com/ubuntu hardy main restricted + +## Major bug fix updates produced after the final release of the +## distribution. +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates main restricted +deb-src http://archive.ubuntu.com/ubuntu hardy-updates main restricted + +## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu +## team, and may not be under a free licence. Please satisfy yourself as to +## your rights to use the software. Also, please note that software in +## universe WILL NOT receive any review or updates from the Ubuntu security +## team. +deb http://ports.ubuntu.com/ubuntu-ports/ hardy universe +deb-src http://archive.ubuntu.com/ubuntu hardy universe +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates universe +deb-src http://archive.ubuntu.com/ubuntu hardy-updates universe + +## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu +## team, and may not be under a free licence. Please satisfy yourself as to +## your rights to use the software. Also, please note that software in +## multiverse WILL NOT receive any review or updates from the Ubuntu +## security team. +deb http://ports.ubuntu.com/ubuntu-ports/ hardy multiverse +deb-src http://archive.ubuntu.com/ubuntu hardy multiverse +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates multiverse +deb-src http://archive.ubuntu.com/ubuntu hardy-updates multiverse + +## Uncomment the following two lines to add software from the 'backports' +## repository. +## N.B. software from this repository may not have been tested as +## extensively as that contained in the main release, although it includes +## newer versions of some applications which may provide useful features. +## Also, please note that software in backports WILL NOT receive any review +## or updates from the Ubuntu security team. +# deb http://ports.ubuntu.com/ubuntu-ports/ hardy-backports main restricted universe multiverse +# deb-src http://archive.ubuntu.com/ubuntu hardy-backports main restricted universe multiverse + +## Uncomment the following two lines to add software from Canonical's +## 'partner' repository. This software is not part of Ubuntu, but is +## offered by Canonical and the respective vendors as a service to Ubuntu +## users. +# deb http://archive.canonical.com/ubuntu hardy partner +# deb-src http://archive.canonical.com/ubuntu hardy partner + +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security main restricted +deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security main restricted +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security universe +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security multiverse +deb-src http://archive.ubuntu.com/ubuntu/ hardy-proposed restricted main multiverse universe diff --git a/tests/old/data/sources.list b/tests/old/data/sources.list deleted file mode 100644 index 5481d4f0..00000000 --- a/tests/old/data/sources.list +++ /dev/null @@ -1,6 +0,0 @@ -# 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 \ No newline at end of file diff --git a/tests/old/data/sources.list.testDistribution b/tests/old/data/sources.list.testDistribution deleted file mode 100644 index 0f40e85a..00000000 --- a/tests/old/data/sources.list.testDistribution +++ /dev/null @@ -1,13 +0,0 @@ -deb http://de.archive.ubuntu.com/ubuntu/ hardy main -deb http://de.archive.ubuntu.com/ubuntu/ hardy restricted -deb http://de.archive.ubuntu.com/ubuntu/ hardy universe -deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates universe multiverse -deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates restricted -deb http://de.archive.ubuntu.com/ubuntu/ hardy-security main -deb http://de.archive.ubuntu.com/ubuntu/ hardy-security multiverse -deb http://ftp.debian.org/debian sid main -deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy main -deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy-backports main -deb http://archive.ubuntu.com/ubuntu/ intrepid main -deb cdrom:[Ubuntu 8.10 _Intrepid Ibex_ - Alpha]/ intrepid main -deb cdrom:[Ubuntu 8.04 _Hardy Heron_] hardy main \ No newline at end of file diff --git a/tests/old/test-data-ports/sources.list b/tests/old/test-data-ports/sources.list deleted file mode 100644 index a6b2f6ed..00000000 --- a/tests/old/test-data-ports/sources.list +++ /dev/null @@ -1,59 +0,0 @@ -# -# deb cdrom:[Ubuntu-Server 8.04.1 _Hardy Heron_ - Release powerpc (20080703)]/ hardy main restricted - -# deb cdrom:[Ubuntu-Server 8.04.1 _Hardy Heron_ - Release powerpc (20080703)]/ hardy main restricted -# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to -# newer versions of the distribution. - -deb http://ports.ubuntu.com/ubuntu-ports/ hardy main restricted -deb-src http://archive.ubuntu.com/ubuntu hardy main restricted - -## Major bug fix updates produced after the final release of the -## distribution. -deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates main restricted -deb-src http://archive.ubuntu.com/ubuntu hardy-updates main restricted - -## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu -## team, and may not be under a free licence. Please satisfy yourself as to -## your rights to use the software. Also, please note that software in -## universe WILL NOT receive any review or updates from the Ubuntu security -## team. -deb http://ports.ubuntu.com/ubuntu-ports/ hardy universe -deb-src http://archive.ubuntu.com/ubuntu hardy universe -deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates universe -deb-src http://archive.ubuntu.com/ubuntu hardy-updates universe - -## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu -## team, and may not be under a free licence. Please satisfy yourself as to -## your rights to use the software. Also, please note that software in -## multiverse WILL NOT receive any review or updates from the Ubuntu -## security team. -deb http://ports.ubuntu.com/ubuntu-ports/ hardy multiverse -deb-src http://archive.ubuntu.com/ubuntu hardy multiverse -deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates multiverse -deb-src http://archive.ubuntu.com/ubuntu hardy-updates multiverse - -## Uncomment the following two lines to add software from the 'backports' -## repository. -## N.B. software from this repository may not have been tested as -## extensively as that contained in the main release, although it includes -## newer versions of some applications which may provide useful features. -## Also, please note that software in backports WILL NOT receive any review -## or updates from the Ubuntu security team. -# deb http://ports.ubuntu.com/ubuntu-ports/ hardy-backports main restricted universe multiverse -# deb-src http://archive.ubuntu.com/ubuntu hardy-backports main restricted universe multiverse - -## Uncomment the following two lines to add software from Canonical's -## 'partner' repository. This software is not part of Ubuntu, but is -## offered by Canonical and the respective vendors as a service to Ubuntu -## users. -# deb http://archive.canonical.com/ubuntu hardy partner -# deb-src http://archive.canonical.com/ubuntu hardy partner - -deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security main restricted -deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security main restricted -deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security universe -deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security universe -deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security multiverse -deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security multiverse -deb-src http://archive.ubuntu.com/ubuntu/ hardy-proposed restricted main multiverse universe diff --git a/tests/old/test_aptsources.py b/tests/old/test_aptsources.py deleted file mode 100644 index 3761f3ff..00000000 --- a/tests/old/test_aptsources.py +++ /dev/null @@ -1,151 +0,0 @@ -#!/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("Dir::Etc", os.getcwd()) - apt_pkg.Config.Set("Dir::Etc::sourceparts", "/xxx") - - def testIsMirror(self): - yes = aptsources.sourceslist.is_mirror("http://archive.ubuntu.com", - "http://de.archive.ubuntu.com") - no = aptsources.sourceslist.is_mirror("http://archive.ubuntu.com", - "http://ftp.debian.org") - self.assertTrue(yes) - self.assertFalse(no) - - def testSourcesListReading(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list") - sources = aptsources.sourceslist.SourcesList() - self.assertEqual(len(sources.list), 6) - # test load - sources.list = [] - sources.load("data/sources.list") - self.assertEqual(len(sources.list), 6) - - def testSourcesListAdding(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list") - sources = aptsources.sourceslist.SourcesList() - # test to add something that is already there (main) - before = copy.deepcopy(sources) - sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", - "edgy", - ["main"]) - self.assertTrue(sources.list == before.list) - # test to add something that is already there (restricted) - before = copy.deepcopy(sources) - sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", - "edgy", - ["restricted"]) - self.assertTrue(sources.list == before.list) - # test to add something new: multiverse - sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", - "edgy", - ["multiverse"]) - 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): - found = True - self.assertTrue(found) - # test to add something new: multiverse *and* - # something that is already there - before = copy.deepcopy(sources) - sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", - "edgy", - ["universe", "something"]) - found_universe = 0 - found_something = 0 - for entry in sources: - if (entry.type == "deb" and - entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and - entry.dist == "edgy"): - for c in entry.comps: - if c == "universe": - found_universe += 1 - if c == "something": - found_something += 1 - #print "\n".join([s.str() for s in sources]) - self.assertEqual(found_something, 1) - self.assertEqual(found_universe, 1) - - def testMatcher(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list.test" - "Distribution") - sources = aptsources.sourceslist.SourcesList() - distro = aptsources.distro.get_distro() - 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) - - def testDistribution(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list.test" - "Distribution") - sources = aptsources.sourceslist.SourcesList() - distro = aptsources.distro.get_distro() - 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 not entry.dist 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 not entry.dist 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) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/old/test_aptsources_ports.py b/tests/old/test_aptsources_ports.py deleted file mode 100644 index 09d6e9d9..00000000 --- a/tests/old/test_aptsources_ports.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/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() diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py new file mode 100644 index 00000000..e5cd1f5a --- /dev/null +++ b/tests/test_aptsources.py @@ -0,0 +1,155 @@ +#!/usr/bin/env python + +import unittest +import os +import copy + +import apt_pkg +import aptsources.sourceslist +import aptsources.distro + + +class TestAptSources(unittest.TestCase): + + def setUp(self): + apt_pkg.init_config() + apt_pkg.init_system() + apt_pkg.config.set("Dir::Etc", os.getcwd()) + apt_pkg.config.set("Dir::Etc::sourceparts", "/xxx") + + def testIsMirror(self): + """Test mirror detection.""" + yes = aptsources.sourceslist.is_mirror("http://archive.ubuntu.com", + "http://de.archive.ubuntu.com") + no = aptsources.sourceslist.is_mirror("http://archive.ubuntu.com", + "http://ftp.debian.org") + self.assertTrue(yes) + self.assertFalse(no) + + def testSourcesListReading(self): + """Test sources.list parsing.""" + apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" + "sources.list") + sources = aptsources.sourceslist.SourcesList() + self.assertEqual(len(sources.list), 6) + # test load + sources.list = [] + sources.load("data/aptsources/sources.list") + self.assertEqual(len(sources.list), 6) + + def testSourcesListAdding(self): + """Test additions to sources.list""" + apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" + "sources.list") + sources = aptsources.sourceslist.SourcesList() + # test to add something that is already there (main) + before = copy.deepcopy(sources) + sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", + "edgy", + ["main"]) + self.assertTrue(sources.list == before.list) + # test to add something that is already there (restricted) + before = copy.deepcopy(sources) + sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", + "edgy", + ["restricted"]) + self.assertTrue(sources.list == before.list) + # test to add something new: multiverse + sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", + "edgy", + ["multiverse"]) + 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): + found = True + self.assertTrue(found) + # test to add something new: multiverse *and* + # something that is already there + before = copy.deepcopy(sources) + sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", + "edgy", + ["universe", "something"]) + found_universe = 0 + found_something = 0 + for entry in sources: + if (entry.type == "deb" and + entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and + entry.dist == "edgy"): + for c in entry.comps: + if c == "universe": + found_universe += 1 + if c == "something": + found_something += 1 + #print "\n".join([s.str() for s in sources]) + self.assertEqual(found_something, 1) + self.assertEqual(found_universe, 1) + + def testMatcher(self): + """Test matcher (detection of what is what in sources.list)""" + apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" + "sources.list.testDistribution") + sources = aptsources.sourceslist.SourcesList() + distro = aptsources.distro.get_distro() + 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) + + def testDistribution(self): + """Test distribution detection.""" + apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" + "sources.list.testDistribution") + sources = aptsources.sourceslist.SourcesList() + distro = aptsources.distro.get_distro() + 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 not entry.dist 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 not entry.dist 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) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_aptsources_ports.py b/tests/test_aptsources_ports.py new file mode 100644 index 00000000..5594ec0b --- /dev/null +++ b/tests/test_aptsources_ports.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python +import os +import unittest + + +import apt_pkg +import aptsources.sourceslist +import aptsources.distro + + +class TestAptSourcesPorts(unittest.TestCase): + """Test aptsources on ports.ubuntu.com.""" + + def setUp(self): + apt_pkg.init_config() + apt_pkg.init_system() + apt_pkg.config.set("APT::Architecture", "powerpc") + apt_pkg.config.set("Dir::Etc", + os.path.abspath("data/aptsources_ports")) + apt_pkg.config.set("Dir::Etc::sourceparts", "/xxx") + + def testMatcher(self): + """Test matcher.""" + 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() diff --git a/tests/test_cache_invocation.py b/tests/test_cache_invocation.py index 9d34891d..39dae8f4 100644 --- a/tests/test_cache_invocation.py +++ b/tests/test_cache_invocation.py @@ -1,16 +1,18 @@ #!/usr/bin/python +import unittest + import apt_pkg -import unittest class TestCache(unittest.TestCase): + """Test invocation of apt_pkg.Cache()""" def setUp(self): apt_pkg.init_config() apt_pkg.init_system() def test_wrong_invocation(self): - """wrongly invoke GetCache() rather than GetDepCache().""" + """Test wrong invocation of apt_pkg.Cache(apt_pkg.Cache())""" apt_cache = apt_pkg.Cache(apt_pkg.OpProgress()) if apt_pkg._COMPAT_0_7: self.assertRaises(ValueError, apt_pkg.Cache, apt_cache) @@ -24,7 +26,7 @@ class TestCache(unittest.TestCase): self.assertRaises(TypeError, apt_pkg.Cache, 0) def test_proper_invocation(self): - """Invoke it the right way.""" + """Test correct invocation of apt_pkg.DepCache(apt_pkg.Cache()).""" apt_cache = apt_pkg.Cache(apt_pkg.OpProgress()) apt_depcache = apt_pkg.DepCache(apt_cache) -- cgit v1.2.3 From 809ff1217079cb8e4790a1bc8f1fe187c8ded358 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 3 Mar 2010 19:37:43 +0100 Subject: * tests/data/aptsources/sources.list.testDistribution: - change one mirror which is not on the mirror list anymore. --- debian/changelog | 2 + po/python-apt.pot | 140 ++++++++++----------- .../data/aptsources/sources.list.testDistribution | 4 +- 3 files changed, 74 insertions(+), 72 deletions(-) (limited to 'tests/data') diff --git a/debian/changelog b/debian/changelog index 0aab0c2a..cb825163 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,8 @@ python-apt (0.7.93.4) unstable; urgency=low - pre-build.sh: update ubuntu mirrors on bzr-buildpackage (and also do this for Debian mirrors) - add break for packagekit-backend-apt (<= 0.4.8-0ubuntu4) + * tests/data/aptsources/sources.list.testDistribution: + - change one mirror which is not on the mirror list anymore. -- Julian Andres Klode Mon, 01 Mar 2010 16:13:22 +0100 diff --git a/po/python-apt.pot b/po/python-apt.pot index 36a04eae..b67d7988 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-01-31 17:09+0100\n" +"POT-Creation-Date: 2010-03-03 19:34+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -23,257 +23,257 @@ msgid "http://changelogs.ubuntu.com/changelogs/pool/%s/%s/%s/%s_%s/changelog" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:13 +#: ../data/templates/Ubuntu.info.in:12 msgid "Ubuntu 10.04 'Lucid Lynx'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:31 +#: ../data/templates/Ubuntu.info.in:30 msgid "Cdrom with Ubuntu 10.04 'Lucid Lynx'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:74 +#: ../data/templates/Ubuntu.info.in:72 msgid "Ubuntu 9.10 'Karmic Koala'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:92 +#: ../data/templates/Ubuntu.info.in:90 msgid "Cdrom with Ubuntu 9.10 'Karmic Koala'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:135 +#: ../data/templates/Ubuntu.info.in:132 msgid "Ubuntu 9.04 'Jaunty Jackalope'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:153 +#: ../data/templates/Ubuntu.info.in:150 msgid "Cdrom with Ubuntu 9.04 'Jaunty Jackalope'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:196 +#: ../data/templates/Ubuntu.info.in:192 msgid "Ubuntu 8.10 'Intrepid Ibex'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:214 +#: ../data/templates/Ubuntu.info.in:210 msgid "Cdrom with Ubuntu 8.10 'Intrepid Ibex'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:258 +#: ../data/templates/Ubuntu.info.in:253 msgid "Ubuntu 8.04 'Hardy Heron'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:276 +#: ../data/templates/Ubuntu.info.in:271 msgid "Cdrom with Ubuntu 8.04 'Hardy Heron'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:313 +#: ../data/templates/Ubuntu.info.in:308 msgid "Ubuntu 7.10 'Gutsy Gibbon'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:331 +#: ../data/templates/Ubuntu.info.in:326 msgid "Cdrom with Ubuntu 7.10 'Gutsy Gibbon'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:366 +#: ../data/templates/Ubuntu.info.in:361 msgid "Ubuntu 7.04 'Feisty Fawn'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:384 +#: ../data/templates/Ubuntu.info.in:379 msgid "Cdrom with Ubuntu 7.04 'Feisty Fawn'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:418 +#: ../data/templates/Ubuntu.info.in:413 msgid "Ubuntu 6.10 'Edgy Eft'" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:423 +#: ../data/templates/Ubuntu.info.in:418 msgid "Community-maintained" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:429 +#: ../data/templates/Ubuntu.info.in:424 msgid "Restricted software" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:436 +#: ../data/templates/Ubuntu.info.in:431 msgid "Cdrom with Ubuntu 6.10 'Edgy Eft'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:470 +#: ../data/templates/Ubuntu.info.in:465 msgid "Ubuntu 6.06 LTS 'Dapper Drake'" msgstr "" #. CompDescriptionLong -#: ../data/templates/Ubuntu.info.in:473 +#: ../data/templates/Ubuntu.info.in:468 msgid "Canonical-supported Open Source software" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:475 +#: ../data/templates/Ubuntu.info.in:470 msgid "Community-maintained (universe)" msgstr "" #. CompDescriptionLong -#: ../data/templates/Ubuntu.info.in:476 +#: ../data/templates/Ubuntu.info.in:471 msgid "Community-maintained Open Source software" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:478 +#: ../data/templates/Ubuntu.info.in:473 msgid "Non-free drivers" msgstr "" #. CompDescriptionLong -#: ../data/templates/Ubuntu.info.in:479 +#: ../data/templates/Ubuntu.info.in:474 msgid "Proprietary drivers for devices" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:481 +#: ../data/templates/Ubuntu.info.in:476 msgid "Restricted software (Multiverse)" msgstr "" #. CompDescriptionLong -#: ../data/templates/Ubuntu.info.in:482 +#: ../data/templates/Ubuntu.info.in:477 msgid "Software restricted by copyright or legal issues" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:488 +#: ../data/templates/Ubuntu.info.in:483 msgid "Cdrom with Ubuntu 6.06 LTS 'Dapper Drake'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:500 +#: ../data/templates/Ubuntu.info.in:495 msgid "Important security updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:505 +#: ../data/templates/Ubuntu.info.in:500 msgid "Recommended updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:510 +#: ../data/templates/Ubuntu.info.in:505 msgid "Pre-released updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:515 +#: ../data/templates/Ubuntu.info.in:510 msgid "Unsupported updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:522 +#: ../data/templates/Ubuntu.info.in:517 msgid "Ubuntu 5.10 'Breezy Badger'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:536 +#: ../data/templates/Ubuntu.info.in:531 msgid "Cdrom with Ubuntu 5.10 'Breezy Badger'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:548 +#: ../data/templates/Ubuntu.info.in:543 msgid "Ubuntu 5.10 Security Updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:553 +#: ../data/templates/Ubuntu.info.in:548 msgid "Ubuntu 5.10 Updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:558 +#: ../data/templates/Ubuntu.info.in:553 msgid "Ubuntu 5.10 Backports" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:565 +#: ../data/templates/Ubuntu.info.in:560 msgid "Ubuntu 5.04 'Hoary Hedgehog'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:579 +#: ../data/templates/Ubuntu.info.in:574 msgid "Cdrom with Ubuntu 5.04 'Hoary Hedgehog'" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:582 ../data/templates/Debian.info.in:148 +#: ../data/templates/Ubuntu.info.in:577 ../data/templates/Debian.info.in:149 msgid "Officially supported" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:591 +#: ../data/templates/Ubuntu.info.in:586 msgid "Ubuntu 5.04 Security Updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:596 +#: ../data/templates/Ubuntu.info.in:591 msgid "Ubuntu 5.04 Updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:601 +#: ../data/templates/Ubuntu.info.in:596 msgid "Ubuntu 5.04 Backports" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:607 +#: ../data/templates/Ubuntu.info.in:602 msgid "Ubuntu 4.10 'Warty Warthog'" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:613 +#: ../data/templates/Ubuntu.info.in:608 msgid "Community-maintained (Universe)" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:615 +#: ../data/templates/Ubuntu.info.in:610 msgid "Non-free (Multiverse)" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:621 +#: ../data/templates/Ubuntu.info.in:616 msgid "Cdrom with Ubuntu 4.10 'Warty Warthog'" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:624 +#: ../data/templates/Ubuntu.info.in:619 msgid "No longer officially supported" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:626 +#: ../data/templates/Ubuntu.info.in:621 msgid "Restricted copyright" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:633 +#: ../data/templates/Ubuntu.info.in:628 msgid "Ubuntu 4.10 Security Updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:638 +#: ../data/templates/Ubuntu.info.in:633 msgid "Ubuntu 4.10 Updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:643 +#: ../data/templates/Ubuntu.info.in:638 msgid "Ubuntu 4.10 Backports" msgstr "" @@ -324,17 +324,17 @@ msgid "Debian testing" msgstr "" #. Description -#: ../data/templates/Debian.info.in:146 +#: ../data/templates/Debian.info.in:147 msgid "Debian 'Sid' (unstable)" msgstr "" #. CompDescription -#: ../data/templates/Debian.info.in:150 +#: ../data/templates/Debian.info.in:151 msgid "DFSG-compatible Software with Non-Free Dependencies" msgstr "" #. CompDescription -#: ../data/templates/Debian.info.in:152 +#: ../data/templates/Debian.info.in:153 msgid "Non-DFSG-compatible Software" msgstr "" @@ -356,39 +356,39 @@ msgstr "" msgid "Custom servers" msgstr "" -#: ../apt/progress/gtk2.py:259 ../apt/progress/gtk2.py:315 +#: ../apt/progress/gtk2.py:260 ../apt/progress/gtk2.py:316 #, python-format msgid "Downloading file %(current)li of %(total)li with %(speed)s/s" msgstr "" -#: ../apt/progress/gtk2.py:265 ../apt/progress/gtk2.py:321 +#: ../apt/progress/gtk2.py:266 ../apt/progress/gtk2.py:322 #, python-format msgid "Downloading file %(current)li of %(total)li" msgstr "" #. Setup some child widgets -#: ../apt/progress/gtk2.py:341 +#: ../apt/progress/gtk2.py:342 msgid "Details" msgstr "" -#: ../apt/progress/gtk2.py:429 +#: ../apt/progress/gtk2.py:430 msgid "Starting..." msgstr "" -#: ../apt/progress/gtk2.py:435 +#: ../apt/progress/gtk2.py:436 msgid "Complete" msgstr "" -#: ../apt/package.py:333 +#: ../apt/package.py:342 #, python-format msgid "Invalid unicode in description for '%s' (%s). Please report." msgstr "" -#: ../apt/package.py:989 ../apt/package.py:1095 +#: ../apt/package.py:999 ../apt/package.py:1105 msgid "The list of changes is not available" msgstr "" -#: ../apt/package.py:1099 +#: ../apt/package.py:1109 #, python-format msgid "" "The list of changes is not available yet.\n" @@ -397,23 +397,23 @@ msgid "" "until the changes become available or try again later." msgstr "" -#: ../apt/package.py:1105 +#: ../apt/package.py:1115 msgid "" "Failed to download the list of changes. \n" "Please check your Internet connection." msgstr "" -#: ../apt/debfile.py:70 +#: ../apt/debfile.py:73 #, python-format msgid "List of files for '%s' could not be read" msgstr "" -#: ../apt/debfile.py:138 +#: ../apt/debfile.py:141 #, python-format msgid "Dependency is not satisfiable: %s\n" msgstr "" -#: ../apt/debfile.py:162 +#: ../apt/debfile.py:165 #, python-format msgid "Conflicts with the installed package '%s'" msgstr "" @@ -437,12 +437,12 @@ msgstr "" msgid "Cannot install '%s'" msgstr "" -#: ../apt/debfile.py:473 +#: ../apt/debfile.py:472 #, python-format msgid "Install Build-Dependencies for source package '%s' that builds %s\n" msgstr "" -#: ../apt/debfile.py:483 +#: ../apt/debfile.py:482 msgid "An essential package would be removed" msgstr "" @@ -493,6 +493,6 @@ msgstr "" msgid "Please insert a Disc in the drive and press enter" msgstr "" -#: ../apt/cache.py:127 +#: ../apt/cache.py:131 msgid "Building data structures" msgstr "" diff --git a/tests/data/aptsources/sources.list.testDistribution b/tests/data/aptsources/sources.list.testDistribution index 4ff0fae6..79224a34 100644 --- a/tests/data/aptsources/sources.list.testDistribution +++ b/tests/data/aptsources/sources.list.testDistribution @@ -6,8 +6,8 @@ deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates restricted deb http://de.archive.ubuntu.com/ubuntu/ hardy-security main deb http://de.archive.ubuntu.com/ubuntu/ hardy-security multiverse deb http://ftp.debian.org/debian sid main -deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy main -deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy-backports main +deb http://ftp.hosteurope.de/mirror/archive.ubuntu.com/ hardy main +deb http://ftp.hosteurope.de/mirror/archive.ubuntu.com/ hardy-backports main deb http://archive.ubuntu.com/ubuntu/ intrepid main deb cdrom:[Ubuntu 8.10 _Intrepid Ibex_ - Alpha]/ intrepid main deb cdrom:[Ubuntu 8.04 _Hardy Heron_] hardy main -- cgit v1.2.3