summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/data/sources.list.testDistribution14
-rw-r--r--tests/test_aptsources.py34
2 files changed, 38 insertions, 10 deletions
diff --git a/tests/data/sources.list.testDistribution b/tests/data/sources.list.testDistribution
new file mode 100644
index 00000000..dd900645
--- /dev/null
+++ b/tests/data/sources.list.testDistribution
@@ -0,0 +1,14 @@
+# 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-security main
+# comment 6
+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 e8b97263..0479076c 100644
--- a/tests/test_aptsources.py
+++ b/tests/test_aptsources.py
@@ -10,9 +10,8 @@ class TestAptSources(unittest.TestCase):
def __init__(self, methodName):
unittest.TestCase.__init__(self, methodName)
apt_pkg.init()
-
- def testAddComponent(self):
- pass
+ apt_pkg.Config.Set("Dir::Etc", os.getcwd())
+ apt_pkg.Config.Set("Dir::Etc::sourceparts",".")
def testIsMirror(self):
self.assertTrue(aptsources.is_mirror("http://archive.ubuntu.com",
@@ -21,17 +20,17 @@ class TestAptSources(unittest.TestCase):
"http://ftp.debian.org"))
def testSourcesListReading(self):
- sources = aptsources.SourcesList()
- # test refresh
- apt_pkg.Config.Set("Dir::Etc", os.getcwd())
apt_pkg.Config.Set("Dir::Etc::sourcelist","data/sources.list")
- apt_pkg.Config.Set("Dir::Etc::sourceparts",".")
- sources.refresh()
+ sources = aptsources.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()
# test to add something that is already there (main)
before = copy.deepcopy(sources)
sources.add("deb","http://de.archive.ubuntu.com/ubuntu/",
@@ -69,7 +68,6 @@ class TestAptSources(unittest.TestCase):
entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and
entry.dist == "edgy"):
for c in entry.comps:
- print c
if c == "universe":
found_universe += 1
if c == "something":
@@ -78,7 +76,23 @@ class TestAptSources(unittest.TestCase):
self.assertEqual(found_something, 1)
self.assertEqual(found_universe, 1)
-
+ def testDistribution(self):
+ apt_pkg.Config.Set("Dir::Etc::sourcelist","data/sources.list.testDistribution")
+ sources = aptsources.SourcesList()
+ distro = aptsources.Distribution()
+ distro.get_sources(sources)
+ comp = "restricted"
+ distro.enable_component(sources, comp)
+ found = 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 == comp:
+ found += 1
+ print "".join([s.str() for s in sources])
+ assertEqual(found, 1)
if __name__ == "__main__":