summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-07-02 10:59:08 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2010-07-02 10:59:08 +0200
commita90b26aad2824d4bd224586cdf14c0ad21059ac3 (patch)
tree3f0ec49f39c18dc81115db265df47d5b077371ca
parent508f1ddb5b6a0cc69655e39dbd59fe3466173a84 (diff)
downloadpython-apt-a90b26aad2824d4bd224586cdf14c0ad21059ac3.tar.gz
add test_progress.py test
-rw-r--r--tests/data/fake-packages/Packages21
-rw-r--r--tests/data/fake-packages/Packages.gzbin0 -> 555 bytes
-rw-r--r--tests/test_progress.py44
3 files changed, 65 insertions, 0 deletions
diff --git a/tests/data/fake-packages/Packages b/tests/data/fake-packages/Packages
new file mode 100644
index 00000000..9fbab957
--- /dev/null
+++ b/tests/data/fake-packages/Packages
@@ -0,0 +1,21 @@
+Package: 2vcard
+Priority: optional
+Section: universe/utils
+Installed-Size: 108
+Maintainer: Arvind Autar <Autar022@planet.nl>
+Architecture: amd64
+Version: 0.5-1ubuntu1
+Filename: pool/universe/2/2vcard/2vcard_0.5-1ubuntu1_amd64.deb
+Size: 14164
+MD5sum: 105ea91f0a75417d0f9e8e9624513b2a
+SHA1: d55beee01c08efc33cd131e106330dca72ee14be
+SHA256: 4a72edaf87cdb826e5508b85311fcf0bec9b7e019a55740ded7feb1b9e197f11
+Description: A little perl script to convert an adressbook to VCARD file format
+ 2vcard is a little perl script that you can use to convert the popular vcard
+ file format. Currently 2vcard can only convert adressbooks and alias files from
+ the following formats: abook,eudora,juno,ldif,mutt,mh and pine.
+ .
+ The VCARD format is used by gnomecard, for example, which is turn is used by
+ the balsa email client.
+Bugs: mailto:ubuntu-users@lists.ubuntu.com
+Origin: Ubuntu
diff --git a/tests/data/fake-packages/Packages.gz b/tests/data/fake-packages/Packages.gz
new file mode 100644
index 00000000..506bc8d4
--- /dev/null
+++ b/tests/data/fake-packages/Packages.gz
Binary files differ
diff --git a/tests/test_progress.py b/tests/test_progress.py
new file mode 100644
index 00000000..2ab8ce5e
--- /dev/null
+++ b/tests/test_progress.py
@@ -0,0 +1,44 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2010 Michael Vogt <mvo@ubuntu.com>
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+"""Unit tests for verifying the correctness of apt.progress"""
+import unittest
+
+import apt
+import apt_pkg
+import os
+
+class TestAcquireProgress(apt.progress.base.AcquireProgress):
+ def pulse(self, owner):
+ self.pulsed = True
+
+class TestProgress(unittest.TestCase):
+
+ def setUp(self):
+ basedir = os.path.abspath(os.path.dirname(__file__))
+ # setup apt_pkg config
+ apt_pkg.init()
+ apt_pkg.config.set("APT::Architecture", "amd64")
+ apt_pkg.config.set("Dir::Etc", basedir)
+ apt_pkg.config.set("Dir::Etc::sourceparts", "/xxx")
+ # setup lists dir
+ if not os.path.exists("./tmp/partial"):
+ os.makedirs("./tmp/partial")
+ apt_pkg.config.set("Dir::state::lists", "./tmp")
+ # create artifical line
+ deb_line = "deb file:%s/data/fake-packages/ /\n" % basedir
+ open("fetch_sources.list","w").write(deb_line)
+ apt_pkg.config.set("Dir::Etc::sourcelist", "fetch_sources.list")
+
+ def test_acquire_progress(self):
+ progress = TestAcquireProgress()
+ cache = apt.Cache()
+ res = cache.update(progress)
+ self.assertTrue(progress.pulsed)
+
+if __name__ == "__main__":
+ unittest.main()