summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_apt_cache.py4
-rw-r--r--tests/test_policy.py39
2 files changed, 41 insertions, 2 deletions
diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py
index 2bc19353..448aed75 100644
--- a/tests/test_apt_cache.py
+++ b/tests/test_apt_cache.py
@@ -190,12 +190,12 @@ class TestAptCache(unittest.TestCase):
def test_package_cmp(self):
cache = apt.Cache(rootdir="/")
l = []
- l.append(cache["libc6"])
+ l.append(cache["intltool"])
l.append(cache["python3"])
l.append(cache["apt"])
l.sort()
self.assertEqual([p.name for p in l],
- ["apt", "libc6", "python3"])
+ ["apt", "intltool", "python3"])
def test_get_architectures(self):
main_arch = apt.apt_pkg.config.get("APT::Architecture")
diff --git a/tests/test_policy.py b/tests/test_policy.py
new file mode 100644
index 00000000..d77fb27e
--- /dev/null
+++ b/tests/test_policy.py
@@ -0,0 +1,39 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2012 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.
+
+import apt
+import unittest
+
+class TestAptPolicy(unittest.TestCase):
+
+ def test_apt_policy_lowlevel(self):
+ # get a policy
+ cache = apt.Cache()
+ policy = cache._depcache.policy
+ self.assertNotEqual(policy, None)
+ # basic tests
+ pkg = cache["apt"]
+ self.assertEqual(policy.get_priority(pkg._pkg), 0)
+ # get priority for all pkgfiles
+ for ver in pkg.versions:
+ lowlevel_ver = ver._cand
+ for pkgfile, i in lowlevel_ver.file_list:
+ #print pkgfile, i, policy.get_priority(pkgfile)
+ self.assertTrue(policy.get_priority(pkgfile) > 1)
+ self.assertTrue(policy.get_priority(pkgfile) < 1001)
+
+ def test_apt_policy_highlevel(self):
+ cache = apt.Cache()
+ pkg = cache["apt"]
+ self.assertTrue(pkg.candidate.policy_priority > 1 and
+ pkg.candidate.policy_priority < 1001)
+
+
+
+if __name__ == "__main__":
+ unittest.main()