diff options
| author | Julian Andres Klode <jak@debian.org> | 2009-07-17 20:53:45 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2009-07-17 20:53:45 +0200 |
| commit | c88f6ea1f3d2cca1ff7f1a22f51318ea3f28c01f (patch) | |
| tree | 597d820fc5bb414139fde654f620c454b5bc2916 /tests | |
| parent | 61481860f4e260e56e123811b759c8d8bd3353db (diff) | |
| download | python-apt-c88f6ea1f3d2cca1ff7f1a22f51318ea3f28c01f.tar.gz | |
tests: Import more tests from tests/old.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/__init__.py | 2 | ||||
| -rw-r--r-- | tests/data/aptsources/sources.list (renamed from tests/old/data/sources.list) | 0 | ||||
| -rw-r--r-- | tests/data/aptsources/sources.list.testDistribution (renamed from tests/old/data/sources.list.testDistribution) | 2 | ||||
| -rw-r--r-- | tests/data/aptsources_ports/sources.list (renamed from tests/old/test-data-ports/sources.list) | 0 | ||||
| -rw-r--r-- | tests/test_aptsources.py (renamed from tests/old/test_aptsources.py) | 34 | ||||
| -rw-r--r-- | tests/test_aptsources_ports.py (renamed from tests/old/test_aptsources_ports.py) | 26 | ||||
| -rw-r--r-- | tests/test_cache_invocation.py | 8 |
7 files changed, 38 insertions, 34 deletions
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/old/data/sources.list b/tests/data/aptsources/sources.list index 5481d4f0..5481d4f0 100644 --- a/tests/old/data/sources.list +++ b/tests/data/aptsources/sources.list diff --git a/tests/old/data/sources.list.testDistribution b/tests/data/aptsources/sources.list.testDistribution index 0f40e85a..4ff0fae6 100644 --- a/tests/old/data/sources.list.testDistribution +++ b/tests/data/aptsources/sources.list.testDistribution @@ -10,4 +10,4 @@ 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 +deb cdrom:[Ubuntu 8.04 _Hardy Heron_] hardy main diff --git a/tests/old/test-data-ports/sources.list b/tests/data/aptsources_ports/sources.list index a6b2f6ed..a6b2f6ed 100644 --- a/tests/old/test-data-ports/sources.list +++ b/tests/data/aptsources_ports/sources.list diff --git a/tests/old/test_aptsources.py b/tests/test_aptsources.py index 3761f3ff..e5cd1f5a 100644 --- a/tests/old/test_aptsources.py +++ b/tests/test_aptsources.py @@ -3,24 +3,22 @@ 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 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", @@ -29,16 +27,20 @@ class TestAptSources(unittest.TestCase): self.assertFalse(no) def testSourcesListReading(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list") + """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/sources.list") + sources.load("data/aptsources/sources.list") self.assertEqual(len(sources.list), 6) def testSourcesListAdding(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list") + """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) @@ -86,8 +88,9 @@ class TestAptSources(unittest.TestCase): self.assertEqual(found_universe, 1) def testMatcher(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list.test" - "Distribution") + """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) @@ -98,8 +101,9 @@ class TestAptSources(unittest.TestCase): self.fail("source entry '%s' has no matcher" % s) def testDistribution(self): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "data/sources.list.test" - "Distribution") + """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) diff --git a/tests/old/test_aptsources_ports.py b/tests/test_aptsources_ports.py index 09d6e9d9..5594ec0b 100644 --- a/tests/old/test_aptsources_ports.py +++ b/tests/test_aptsources_ports.py @@ -1,29 +1,27 @@ #!/usr/bin/env python - +import os 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): +class TestAptSourcesPorts(unittest.TestCase): + """Test aptsources on ports.ubuntu.com.""" - 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 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): - apt_pkg.Config.Set("Dir::Etc::sourcelist", "sources.list") + """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") 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) |
