summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/data/aptsources/sources.list5
-rw-r--r--tests/test_aptsources.py55
2 files changed, 57 insertions, 3 deletions
diff --git a/tests/data/aptsources/sources.list b/tests/data/aptsources/sources.list
index 5481d4f0..376d6961 100644
--- a/tests/data/aptsources/sources.list
+++ b/tests/data/aptsources/sources.list
@@ -3,4 +3,7 @@ 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
+deb http://de.archive.ubuntu.com/ubuntu/ edgy universe
+
+# multi-arch
+deb [arch=amd64,i386] http://de.archive.ubuntu.com/ubuntu/ natty main
diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py
index 331df935..1597674e 100644
--- a/tests/test_aptsources.py
+++ b/tests/test_aptsources.py
@@ -39,11 +39,11 @@ class TestAptSources(unittest.TestCase):
apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/"
"sources.list")
sources = aptsources.sourceslist.SourcesList(True, self.templates)
- self.assertEqual(len(sources.list), 6)
+ self.assertEqual(len(sources.list), 9)
# test load
sources.list = []
sources.load("data/aptsources/sources.list")
- self.assertEqual(len(sources.list), 6)
+ self.assertEqual(len(sources.list), 9)
def testSourcesListAdding(self):
"""aptsources: Test additions to sources.list"""
@@ -62,6 +62,14 @@ class TestAptSources(unittest.TestCase):
"edgy",
["restricted"])
self.assertTrue(sources.list == before.list)
+
+ before = copy.deepcopy(sources)
+ sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/",
+ "natty",
+ ["main"], architectures=["amd64", "i386"])
+ self.assertTrue(sources.list == before.list)
+
+
# test to add something new: multiverse
sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/",
"edgy",
@@ -74,6 +82,34 @@ class TestAptSources(unittest.TestCase):
"multiverse" in entry.comps):
found = True
self.assertTrue(found)
+
+ # add a new natty entry without architecture specification
+ sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/",
+ "natty",
+ ["multiverse"])
+ found = False
+ for entry in sources:
+ if (entry.type == "deb" and
+ entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and
+ entry.dist == "natty" and
+ entry.architectures == [] and
+ "multiverse" in entry.comps):
+ found = True
+ self.assertTrue(found)
+
+ # Add universe to existing multi-arch line
+ sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/",
+ "natty",
+ ["universe"], architectures=["i386", "amd64"])
+ found = False
+ for entry in sources:
+ if (entry.type == "deb" and
+ entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and
+ entry.dist == "natty" and
+ set(entry.architectures) == set(["amd64", "i386"]) and
+ set(entry.comps) == set(["main", "universe"])):
+ found = True
+ self.assertTrue(found)
# test to add something new: multiverse *and*
# something that is already there
before = copy.deepcopy(sources)
@@ -108,6 +144,21 @@ class TestAptSources(unittest.TestCase):
if not s.template:
self.fail("source entry '%s' has no matcher" % s)
+ def testMultiArch(self):
+ """aptsources: Test multi-arch parsing"""
+
+ apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/"
+ "sources.list")
+ sources = aptsources.sourceslist.SourcesList(True, self.templates)
+
+ assert sources.list[8].invalid == False
+ assert sources.list[8].type == "deb"
+ assert sources.list[8].architectures == ["amd64", "i386"]
+ assert sources.list[8].uri == "http://de.archive.ubuntu.com/ubuntu/"
+ assert sources.list[8].dist == "natty"
+ assert sources.list[8].comps == ["main"]
+ assert sources.list[8].line.strip() == str(sources.list[8])
+
def testDistribution(self):
"""aptsources: Test distribution detection."""
apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/"