summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/data/sources.list.testDistribution22
-rw-r--r--tests/test_aptsources.py42
-rwxr-xr-xtests/test_debextract.py13
-rw-r--r--tests/test_extract_archive.py10
4 files changed, 64 insertions, 23 deletions
diff --git a/tests/data/sources.list.testDistribution b/tests/data/sources.list.testDistribution
index 1687c504..0f40e85a 100644
--- a/tests/data/sources.list.testDistribution
+++ b/tests/data/sources.list.testDistribution
@@ -1,11 +1,13 @@
-deb http://de.archive.ubuntu.com/ubuntu/ edgy main
-deb http://de.archive.ubuntu.com/ubuntu/ edgy restricted
-deb http://de.archive.ubuntu.com/ubuntu/ edgy universe
-deb http://de.archive.ubuntu.com/ubuntu/ edgy-updates universe multiverse
-deb http://de.archive.ubuntu.com/ubuntu/ edgy-updates restricted
-deb http://de.archive.ubuntu.com/ubuntu/ edgy-security main
-deb http://de.archive.ubuntu.com/ubuntu/ edgy-security multiverse
+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 ftp://ubuntu.cs.utah.edu/pub/ubuntu/ubuntu/ breezy main
-deb ftp://ubuntu.cs.utah.edu/pub/ubuntu/ubuntu/ breezy-backports main
-deb http://archive.ubuntu.com/ubuntu/ hoary 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/test_aptsources.py b/tests/test_aptsources.py
index 3ee106be..49fe6afa 100644
--- a/tests/test_aptsources.py
+++ b/tests/test_aptsources.py
@@ -1,27 +1,32 @@
#!/usr/bin/env python
-import UpdateManager.Common.aptsources as aptsources
import unittest
import apt_pkg
import os
import copy
+import sys
+sys.path.insert(0, "../")
+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",".")
+ apt_pkg.Config.Set("Dir::Etc::sourceparts","/xxx")
def testIsMirror(self):
- self.assertTrue(aptsources.is_mirror("http://archive.ubuntu.com",
- "http://de.archive.ubuntu.com"))
- self.assertFalse(aptsources.is_mirror("http://archive.ubuntu.com",
- "http://ftp.debian.org"))
+ self.assertTrue(aptsources.sourceslist.is_mirror("http://archive.ubuntu.com",
+ "http://de.archive.ubuntu.com"))
+ self.assertFalse(aptsources.sourceslist.is_mirror("http://archive.ubuntu.com",
+ "http://ftp.debian.org"))
def testSourcesListReading(self):
apt_pkg.Config.Set("Dir::Etc::sourcelist","data/sources.list")
- sources = aptsources.SourcesList()
+ sources = aptsources.sourceslist.SourcesList()
self.assertEqual(len(sources.list), 6)
# test load
sources.list = []
@@ -30,7 +35,7 @@ class TestAptSources(unittest.TestCase):
def testSourcesListAdding(self):
apt_pkg.Config.Set("Dir::Etc::sourcelist","data/sources.list")
- sources = aptsources.SourcesList()
+ 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/",
@@ -76,10 +81,21 @@ class TestAptSources(unittest.TestCase):
self.assertEqual(found_something, 1)
self.assertEqual(found_universe, 1)
+ def testMatcher(self):
+ apt_pkg.Config.Set("Dir::Etc::sourcelist","data/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):
apt_pkg.Config.Set("Dir::Etc::sourcelist","data/sources.list.testDistribution")
- sources = aptsources.SourcesList()
- distro = aptsources.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()
@@ -87,11 +103,11 @@ class TestAptSources(unittest.TestCase):
if s.template:
dist_templates.add(s.template.name)
#print dist_templates
- for d in ["edgy","edgy-security","edgy-updates","hoary","breezy", "breezy-backports"]:
+ for d in ["hardy","hardy-security","hardy-updates","intrepid","hardy-backports"]:
self.assertTrue(d in dist_templates)
# test enable
comp = "restricted"
- distro.enable_component(sources, comp)
+ distro.enable_component(comp)
found = {}
for entry in sources:
if (entry.type == "deb" and
@@ -108,7 +124,7 @@ class TestAptSources(unittest.TestCase):
# add a not-already available component
comp = "multiverse"
- distro.enable_component(sources, comp)
+ distro.enable_component(comp)
found = {}
for entry in sources:
if (entry.type == "deb" and
diff --git a/tests/test_debextract.py b/tests/test_debextract.py
new file mode 100755
index 00000000..53241e92
--- /dev/null
+++ b/tests/test_debextract.py
@@ -0,0 +1,13 @@
+#!/usr/bin/python
+
+import apt_inst
+import sys
+
+def Callback(What,Name,Link,Mode,UID,GID,Size,MTime,Major,Minor):
+ print "%s '%s','%s',%u,%u,%u,%u,%u,%u,%u" % (
+ What,Name,Link,Mode,UID,GID,Size, MTime, Major, Minor)
+
+member = "data.tar.lzma"
+if len(sys.argv) > 2:
+ member = sys.argv[2]
+apt_inst.debExtract(open(sys.argv[1]), Callback, member)
diff --git a/tests/test_extract_archive.py b/tests/test_extract_archive.py
new file mode 100644
index 00000000..ce202b06
--- /dev/null
+++ b/tests/test_extract_archive.py
@@ -0,0 +1,10 @@
+#!/usr/bin/python
+
+import apt
+import apt_inst
+import os
+import sys
+
+print os.getcwd()
+apt_inst.debExtractArchive(open(sys.argv[1]), "/tmp/")
+print os.getcwd()