summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/data/test-provides/etc/apt/sources.list1
-rw-r--r--tests/data/test-provides/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_oneiric_main_binary-i386_Packages75
-rw-r--r--tests/data/test-provides/var/lib/dpkg/status0
-rw-r--r--tests/test_apt_cache.py16
4 files changed, 89 insertions, 3 deletions
diff --git a/tests/data/test-provides/etc/apt/sources.list b/tests/data/test-provides/etc/apt/sources.list
new file mode 100644
index 00000000..2955b5c3
--- /dev/null
+++ b/tests/data/test-provides/etc/apt/sources.list
@@ -0,0 +1 @@
+deb http://archive.ubuntu.com/ubuntu oneiric main
diff --git a/tests/data/test-provides/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_oneiric_main_binary-i386_Packages b/tests/data/test-provides/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_oneiric_main_binary-i386_Packages
new file mode 100644
index 00000000..f991cb96
--- /dev/null
+++ b/tests/data/test-provides/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_oneiric_main_binary-i386_Packages
@@ -0,0 +1,75 @@
+Package: exim4-daemon-light
+Priority: extra
+Section: mail
+Installed-Size: 1092
+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
+Original-Maintainer: Exim4 Maintainers <pkg-exim4-maintainers@lists.alioth.debian.org>
+Architecture: all
+Source: exim4
+Version: 4.76-2ubuntu1
+Replaces: mail-transport-agent
+Provides: mail-transport-agent
+Conflicts: mail-transport-agent
+Filename: pool/main/e/exim4/exim4-daemon-light_4.76-2ubuntu1_i386.deb
+Size: 451088
+MD5sum: 81795887e233ecfb3471e8a3da4c4b8b
+SHA1: da0202f7da88b9e9c5ee326a24c3fdd640543a5d
+SHA256: 5ffa03674b5198d1c0e9e0d9e3442cdd7fbe13226c7df91aa53def1f8b6c0d86
+Description: lightweight Exim MTA (v4) daemon
+ Exim (v4) is a mail transport agent. This package contains the exim4
+ daemon with only basic features enabled. It works well with the
+ standard setups that are provided by Debian and includes support for
+ TLS encryption and the dlopen patch to allow dynamic loading of a
+ local_scan function.
+ .
+ The Debian exim4 packages have their own web page,
+ http://pkg-exim4.alioth.debian.org/. There is also a Debian-specific
+ FAQ list. Information about the way the Debian packages are
+ configured can be found in
+ /usr/share/doc/exim4-base/README.Debian.gz, which additionally contains
+ information about the way the Debian binary packages are built. The
+ very extensive upstream documentation is shipped in
+ /usr/share/doc/exim4-base/spec.txt.gz. To repeat the debconf-driven
+ configuration process in a standard setup, invoke dpkg-reconfigure
+ exim4-config. There is a Debian-centered mailing list,
+ pkg-exim4-users@lists.alioth.debian.org. Please ask Debian-specific
+ questions there, and only write to the upstream exim-users mailing
+ list if you are sure that your question is not Debian-specific. You
+ can find the subscription web page on
+ http://lists.alioth.debian.org/mailman/listinfo/pkg-exim4-users
+Homepage: http://www.exim.org/
+Bugs: https://bugs.launchpad.net/ubuntu/+filebug
+Origin: Ubuntu
+Supported: 18m
+
+Package: postfix
+Priority: optional
+Section: mail
+Installed-Size: 3472
+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
+Original-Maintainer: LaMont Jones <lamont@debian.org>
+Architecture: all
+Version: 2.8.3-1ubuntu1
+Replaces: mail-transport-agent
+Provides: default-mta, mail-transport-agent
+Recommends: python
+Suggests: procmail, postfix-mysql, postfix-pgsql, postfix-ldap, postfix-pcre, sasl2-bin, libsasl2-modules, dovecot-common, resolvconf, postfix-cdb, mail-reader, ufw
+Conflicts: libnss-db (<< 2.2-3), mail-transport-agent, smail
+Filename: pool/main/p/postfix/postfix_2.8.3-1ubuntu1_i386.deb
+Size: 1221834
+MD5sum: c4575f03ef0711cc744d394ae36f4a8c
+SHA1: f0f636c942981782cf23cee3d8a95aee188081b9
+SHA256: 13a4bfaf10c8addfc7dce01c0ea65bfbd6a759c4a2aaaafbae5855d099925fe0
+Description: High-performance mail transport agent
+ Postfix is Wietse Venema's mail transport agent that started life as an
+ alternative to the widely-used Sendmail program. Postfix attempts to
+ be fast, easy to administer, and secure, while at the same time being
+ sendmail compatible enough to not upset existing users. Thus, the outside
+ has a sendmail-ish flavor, but the inside is completely different.
+Homepage: http://www.postfix.org
+Bugs: https://bugs.launchpad.net/ubuntu/+filebug
+Origin: Ubuntu
+Supported: 18m
+Task: mail-server
+
+
diff --git a/tests/data/test-provides/var/lib/dpkg/status b/tests/data/test-provides/var/lib/dpkg/status
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/data/test-provides/var/lib/dpkg/status
diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py
index 916a43cb..2f812059 100644
--- a/tests/test_apt_cache.py
+++ b/tests/test_apt_cache.py
@@ -17,9 +17,17 @@ sys.path.insert(0, get_library_dir())
import apt
import apt_pkg
-import copy
import shutil
import glob
+import logging
+
+def if_sources_list_is_readable(f):
+ def wrapper(*args, **kwargs):
+ if os.access("/etc/apt/sources.list", os.R_OK):
+ f(*args, **kwargs)
+ else:
+ logging.warn("skipping '%s' because sources.list is not readable" % f)
+ return wrapper
class TestAptCache(unittest.TestCase):
""" test the apt cache """
@@ -36,6 +44,7 @@ class TestAptCache(unittest.TestCase):
for item in self._cnf:
apt_pkg.config.set(item, self._cnf[item])
+ @if_sources_list_is_readable
def test_apt_cache(self):
"""cache: iterate all packages and all dependencies """
cache = apt.Cache()
@@ -79,7 +88,7 @@ class TestAptCache(unittest.TestCase):
cache = highlevel_cache._cache
l = cache["mail-transport-agent"].provides_list
# arbitrary number, just needs to be higher enough
- self.assertTrue(len(l) > 5)
+ self.assertEqual(len(l), 2)
for (providesname, providesver, version) in l:
self.assertEqual(providesname, "mail-transport-agent")
if version.parent_pkg.name == "postfix":
@@ -87,7 +96,7 @@ class TestAptCache(unittest.TestCase):
else:
self.assertNotReached()
-
+ @if_sources_list_is_readable
def test_dpkg_journal_dirty(self):
# create tmp env
tmpdir = tempfile.mkdtemp()
@@ -106,6 +115,7 @@ class TestAptCache(unittest.TestCase):
open(os.path.join(dpkg_dir,"updates","000"), "w").close()
self.assertTrue(cache.dpkg_journal_dirty)
+ @if_sources_list_is_readable
def test_apt_update(self):
rootdir = "./data/tmp"
if os.path.exists(rootdir):